-
-
Save christiannagel/e22d93036f91f77c50bee2d57b3c0ff5 to your computer and use it in GitHub Desktop.
Get books using EF Core lazy loading
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
public void GetBooksWithLazyLoading() | |
{ | |
var books = _booksContext.Books.Where(b => b.Publisher.StartsWith("Wrox")); | |
foreach (var book in books) | |
{ | |
Console.WriteLine(book.Title); | |
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