KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to compose the results of two Linq Expressions. They exist in the form Expression<Func<T, bool>> So the two that I want to compose are essentially delegates on a parameter (of type T) that both return a boolean. The result I would like composed would be the logical evaluation of the booleans. I would probably implement it as an extension method so my syntax would be something like: Expression<Func<User, bool>> expression1 = t => t.Name == "steve"; Expression<Func<User, bool>> expression2 = t => t.Age == 28; Expression<Func<User, bool>> composedExpression = expression1.And(expression2); And later on in my code I want to evaluate the composed expression var user = new User(); bool evaluated = composedExpression.Compile().Invoke(user); I have poked around with a few different ideas but I fear that it is more complex than I had hoped. How is this done?
Tags (comma-separated)
Save Edits
Cancel