Skip to content

Instantly share code, notes, and snippets.

Last active Jan 27, 2019
What would you like to do?
Get books using EF Core lazy loading
public void GetBooksWithLazyLoading()
var books = _booksContext.Books.Where(b => b.Publisher.StartsWith("Wrox"));
foreach (var book in books)
foreach (var chapter in book.Chapters)
Console.WriteLine($"{chapter.Number}. {chapter.Title}");
Console.WriteLine($"author: {book.Author?.Name}");
Console.WriteLine($"reviewer: {book.Reviewer?.Name}");
Console.WriteLine($"editor: {book.Editor?.Name}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment