Adding LambaExpression to an instance of IQueryable
Posted
by Paul Knopf
on Stack Overflow
See other posts from Stack Overflow
or by Paul Knopf
Published on 2010-03-17T08:16:47Z
Indexed on
2010/03/17
8:21 UTC
Read the original article
Hit count: 193
LINQ
|lambda-expressions
ParameterExpression parameter = Expression.Parameter(typeof(Product), "x");
MemberExpression Left = Expression.MakeMemberAccess(parameter, typeof(Product).GetProperty("Name"));
ConstantExpression Right = Expression.Constant(value, typeof(String));
BinaryExpression expression = Expression.Equal(Left, Right);
LambdaExpression lambada = Expression.Lambda<Func<Product, bool>>(expression, parameter);
Now how do I add this lambada to an instance of an IQuerybale, lets say _query
_query.Where(lambada.Compile());?
© Stack Overflow or respective owner