Last active
November 30, 2015 21:53
-
-
Save johnw86/eff12838f4b69cfb04de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Basic equals expression */ | |
//Line by line | |
ParameterExpression pe = Expression.Parameter(typeof(Object), "x"); | |
Expression left = Expression.Property(pe, typeof(Object).GetProperty("PropertyName")); | |
Expression right = Expression.Constant("value"); | |
Expression expression = Expression.Equal(left, right); | |
var lambda = Expression.Lambda<Func<Object, bool>>(expression, pe); | |
// Short hand | |
var param = Expression.Parameter(typeof(Object), "x"); | |
var exp = Expression.Lambda<Func<Object, bool>>( | |
Expression.Equal( | |
Expression.Property(param, "PropertyName"), | |
Expression.Constant("value") | |
), | |
param | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment