I’m drawing inspiration from this question:
Convert Linq to Sql Expression to Expression Tree
The original poster asked how to convert this to an Expression tree and got a good answer which can be seen in the above link.
List<Region> lst = (from r in dc.Regions
where r.RegionID > 2 && r.RegionDescription.Contains("ern")
select r).ToList();
How would I got about making a property with a get method that returns a bool that uses the ExpressionTree? I’d like to be able to do something like this (obviously I don’t need the == true):
List<Region> lst = (from r in dc.Regions
where (r.AwesomeProperty == true)
select r).ToList();
How would I go about defining AwesomeProperty?
You would define
AwesomePropertyjust like any other property on your LINQ to SQL object. Assuming it is typed asbool(since you compare it totrue), you would build theWherequery like this: