Last active
December 23, 2015 13:19
-
-
Save mikecole/6641186 to your computer and use it in GitHub Desktop.
Eager Loading - More Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var posts = context.Posts | |
.Include(p => p.Author.JobTitle) //We are going two levels deep | |
.ToArray(); | |
//We are going two levels deep here, also. However, since Authors.Posts is a collection, we | |
//need to do a little LINQ-Fu to properly include Categories. | |
var author = context.Authors | |
.Include(a => a.Posts.Select(p => p.Category)) | |
.Single(a => a.ID == id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment