Created
August 14, 2019 18:34
-
-
Save GeradeDev/596be615b7f7fd00fb2077b0c2df829d to your computer and use it in GitHub Desktop.
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
using (var context = new OrderingDbContext()) | |
{ | |
// Load all Orders and related Line Items | |
var orders = context.Order | |
.Include(b => b.LineItem) | |
.ToList(); | |
// Load an Order and it's related Line Items | |
var orders = context.Order | |
.Where(x => x.OrderId == orderId) | |
.Include(b => b.LineItem) | |
.ToList(); | |
// Multiple levels deep | |
// Load all order, all related line items, and all related reviews for that line item (product) | |
var orders1 = context.Order | |
.Include(b => b.LineItem.Select(p => p.Review)) | |
.ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment