This is EF6. I can include .Include()
method (no puns intended) in my queries to eager-load information from related tables. However it looks like .Include() method accepts a string parameter only. Is there a way to do it in a strongly-typed way? So for example, instead of writing MyContext.catalog_item.Include("picture")
, I could write something like MyDB.catalog_item.Include(i => i.picture)
to gain advantages like intellisense and all that.
DbQuery.Include() method: Is there a strong-typed variant?
Asked Answered
Yep, there is a strongly typed variant in System.Data.Entity
Usage is
.Include(i => i.Property)
The reference page gives examples on how to include collections and properties on collections as well.
Example:
query.Include(e => e.Level1Collection.Select(l1 => l1.Level2Reference)).
There's IQueryable
extention method added in EF 5:
http://msdn.microsoft.com/en-us/library/gg671236%28v=vs.103%29.aspx
You may want to have a look at how to perform includes of nested navigation properties
© 2022 - 2024 — McMap. All rights reserved.