using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq.Expressions;
using System.Reflection;


namespace TestApplication
{

    public static class ExpressionUtil
    {
        /// <summary>
        /// Returns the member's name for the given lambda expression
        /// </summary>
        public static string ToName<T>(Expression<Func<T>> expression)
        {
            return ((MemberExpression)expression.Body).Member.Name;
        }

        /// <summary>
        /// Returns the PropertyInfo for the given lambda expression
        /// </summary>
        public static PropertyInfo ToPropertyInfo<T>(Expression<Func<T>> expression)
        {
            return (PropertyInfo)((MemberExpression)expression.Body).Member;
        }


    }

}

