I have a method like:
public Expression<Func<Person, bool>> FilterPeople(string searchCriteria)
{
return (person =>
person.Address.Line1.Contains(searchCriteria) ||
person.Address.Line2.Contains(searchCriteria) ||
person.Address.Line3.Contains(searchCriteria));
}
This method is used in conjunction with Entity Framework to perform a Where()
filter on the results (the real code as a few more conditions than this example).
If I wanted to shorten person.Address
to something more manageable, like a
, I can't figure out how I would do that.
I thought something like Ref Locals would do the trick, but I can't work out how to assign that inside the expression body.
Any ideas?