I created a repository using lambda expressions to filter my collections of entities. As a method parameter, I send Expression<Func<Case, bool>> exp
. But inside the method, I would like to update the same expression with some global filters. I see that the expression object itself received the Update method, but I canโt understand how it is implemented (and I canโt find anything when searching the network).
exp.Update(exp.Body, ???);
Can anyone give an example?
EDIT: method definition: http://msdn.microsoft.com/en-us/library/ee378255.aspx
EDIT 2: This is my code (where I am trying to use. And):
Expression<Func<Case, bool>> newExp = c => c.CaseStatusId != (int)CaseStatus.Finished var binExp = Expression.And(exp.Body, newExp.Body); ParameterExpression paramExp = Expression.Parameter(typeof(Expression<Func<Case, bool>>), "c"); return repository.Where(Expression.Lambda<Expression<Func<Case, bool>>>(binExp, new[] { paramExp }).Compile()).ToArray();
Failure with the following ArgumentException: lambda-type parameter must be obtained from System.Delegate
source share