Skip to content

Instantly share code, notes, and snippets.

@venblee
Created June 26, 2013 17:38
Show Gist options
  • Save venblee/5869544 to your computer and use it in GitHub Desktop.
Save venblee/5869544 to your computer and use it in GitHub Desktop.
Including GrandChildren in .Include()
using (var db = new PmsContext())
{
var dbresult = new Models.PurchaseOrder();
dbresult = db.PurchaseOrders
.Include("PurchaseOrderDetail")
.Include("PurchaseStatus")
.Include("RequestedEmployee")
// GrandChildren
.Include("Supplier.PostalCode")
.Include("Supplier.PostalState")
.Include("Supplier.PostalCity")
// GrandChildren
.Include("Supplier.PhysicalCode")
.Include("Supplier.PhysicalState")
.Include("Supplier.PhysicalCity")
.Include("ModifyEmployee")
.Include("BuyerEmployee")
.Include("ApproverEmployee")
.FirstOrDefault(x => x.PurchaseOrderId == orderid);
return dbresult;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment