I am using Entity Framework 4.3.1 with the Code First approach. In addition, I use LinqKit to use PredicateBuilder.
If I have tables like:
Location, TimeZone (many: 1)
.. and I want to have something like this:
Expression<Func<TimeZone, bool>> pred = PredicateBuilder.True<TimeZone>();
pred = pred.And(tz => tz.TimeZoneCode == "EST");
List<Location> locations = context.Locations
.AsExpandable().Where(pred)
.Select(loc => loc).ToList();
This does not work because the predicate is built to accept TimeZone, but the Where () method gets the location.
I can rewrite the predicate in the same way, but I donโt want to, because I want to have a factory predicate that creates predicates for certain types (I donโt want to use the Navigator properties this way):
Expression<Func<Location, bool>> pred = PredicateBuilder.True<Location>();
pred = pred.And(loc => loc.TimeZone.TimeZoneCode == "EST");
( ) , , TimeZone, , ( ). , , EF , , .