I am using Entity Framework 4.1 Code First and also using PredicateBuilder so that I can create predicate expressions in several specification classes (using the specification template). I can build the predicate correctly and apply it to the DbSet, and the data that I get is what I expect. However, no matter what I try, it is always a lazy load. This is a simple example of how I construct a predicate and apply it.
IQueryable<HairColor> hairColorQuery = Context.Set<HairColor>().AsExpandable(); Expression<Func<Parent, bool>> parentPredicate = PredicateBuilder.And(PredicateBuilder.True<Parent>(), p => p.NameLast.StartsWith("V")).Expand(); Expression<Func<HairColor, bool>> hairColorPredicate = PredicateBuilder.And(PredicateBuilder.True<HairColor>(), h => h.Parents.AsQueryable().Any(parentPredicate)); HairColor[] hairColors = hairColorQuery.Where(hairColorPredicate).Include(h => h.Parents).ToArray();
As I said above, I get the data I want back, but it ignores Include.
Does anyone have any ideas?
source share