using System.Diagnostics;
using System.Linq.Expressions;
using System.Collections.Generic;
public static void Main()
var stopwatch = new Stopwatch();
Expression<Func<A, object>> propertyExpression;
propertyExpression = x => x.PropStr1;
for (int i = 0; i < 99999999; i++)
var x = propertyExpression;
Console.WriteLine(stopwatch.Elapsed);
public string PropStr1 { get; private set; } = "AAA";
public string PropStr2 { get; private set; } = "BBB";
public string PropStr3 { get; private set; } = "CCC";
public static class ExpressionUtils
public static string GetPropertyNameFromExpression<TModel, TPropertyX>(Expression<Func<TModel, TPropertyX>> propertyExpression)
return ((MemberExpression)propertyExpression.Body).Member.Name;
public static Type GetPropertyTypeFromExpression<TModel, TPropertyX>(Expression<Func<TModel, TPropertyX>> propertyExpression)
return ((MemberExpression)propertyExpression.Body).Type;