Return to Snippet

Revision: 23754
at February 12, 2010 07:14 by jmcd


Initial Code
var parameterExpression = Expression.Parameter(typeof(ParentType), "x");
var memberExpression = Expression.Property(parameterExpression, propertyName);
var result = (Expression<Func<ParentType, PropertyType>>)Expression.Lambda(memberExpression, parameterExpression);

Initial URL


Initial Description
Creating the equivalent of (ParentType x) => x.SomeProperty when the property is unknown until runtime

Initial Title
Dynamicaly Creating Expression Accessing a Property

Initial Tags


Initial Language
C#