下面的示例在查询客户时检索一组相关实体。在哪里可以找到递归遍历关系图并自动包含所有关系图的示例?
using(Entities context = new Entities())
{
return context.Customers
.Include("Address")
.Include("Address.State")
.Include("Address.State.Country")
.Include("Phone")
.Include("Phone.PhoneType").Single(c => c.LastName.StartsWith("Jo");
}与
using(Entities context = new Entities())
{
return context.Customers.IncludeAll().Single(c => c.LastName.StartsWith("Jo");
}发布于 2011-10-22 16:28:54
这样如何:
context.Customers.Include(c => c.Address.State.Country)
.Include(c => c.Phone.PhoneType)
.Single(c => c.LastName.StartsWith("Jo");您不希望包含所有内容,因为并非在所有情况下,您都需要所有内容。
https://stackoverflow.com/questions/7744964
复制相似问题