I have following code:
public class MyClass
{
Expression> Criteria {get; set;}
}
public class Customer
{
//..
publ
If you want an expression, then you can use LinqKit to do the following:
Expression> p = x => x.Name;
var c = new MyClass();
c.Criteria = x => p.Invoke(x).StartsWith("asd"); //Reuse p expression
c.Criteria = c.Criteria.Expand();
Invoke is an extension method provided by LinqKit that helps you to compose expressions easily.
After invoking the Expand method, c.Criteria would contain an expression that is exactly the same as if you have done this:
c.Criteria = x => x.Name.StartsWith("asd");