I am using Entity Framework 4.3.1 with a Code First approach. Also, I am using LinqKit so as to use the PredicateBuilder.
If I have tables like so:
Location,
After about a week's worth of struggling, I found out that you can in fact do this. The steps are:
subPredicate)Invoke that subPredicate from within another Predicate (predicate), against the property of the parent object.Expand your predicate when using it in your Where clause.Here's the revised code for your example:
var subPredicate = PredicateBuilder.True();
subPredicate = subPredicate.And(tz => tz.TimeZoneCode == "EST");
var predicate = PredicateBuilder.True();
predicate = predicate.And(l => subPredicate.Invoke(l.TimeZone));
List locations = context.Locations
.AsExpandable().Where(pred.Expand())
.Select(loc => loc).ToList();