Tutorial by Examples

Consider the following C# code Expression<Func<int, int>> expression = a => a + 1; Because the C# compiler sees that the lambda expression is assigned to an Expression type rather than a delegate type it generates an expression tree roughly equivalent to this code ParameterExpres...
To build up an expression like _ => _.Field == "VALUE" at runtime. Given a predicate _ => _.Field and a string value "VALUE", create an expression that tests whether or not the predicate is true. The expression is suitable for: IQueryable<T>, IEnumerable<T>...
Having example type like this: public TestClass { public static string StaticPublicField = "StaticPublicFieldValue"; } We can retrieve value of StaticPublicField: var fieldExpr = Expression.Field(null, typeof(TestClass), "StaticPublicField"); var labmda = Expression....
InvocationExpression class allows invocation of other lambda expressions that are parts of the same Expression tree. You create them with static Expression.Invoke method. Problem We want to get on the items which have "car" in their description. We need to check it for null before searc...

Page 1 of 1