实体框架递归包括收集来自包括收集每个实体 [英] Entity Framework recursively include collection for each entity from included collection
本文介绍了实体框架递归包括收集来自包括收集每个实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在哪里,我想包括在国家的城市人的地址如下。
国家国家= _db.Countries
.INCLUDE(p => p.Cities.People ????)
。凡(....)
不知道如何解决它?
解决方案
从文档:
要包括集合,集合,和参考两个层次下来:
query.Include(E => e.Level1Collection.Select(L1 => l1.Level2Collection.Select(L2 => l2.Level3Reference)))。
块引用>
所以你的情况尝试
国家的国家= _db.Countries
.INCLUDE(C => c.Cities.Select(
CC => cc.People 。选择(
P => p.Addresses)))
。凡(....)
进入该扩展方法要求指令
使用System.Data.Entity的;
I have the following where I am trying to include the addresses of the people in the cities of the countries.
Country country = _db.Countries .Include(p=>p.Cities.People.????) .Where(....)
Not sure how to work it?
解决方案From the documentation:
To include a collection, a collection, and a reference two levels down:
query.Include(e => e.Level1Collection.Select(l1 => l1.Level2Collection.Select(l2 => l2.Level3Reference))).
So in your case try
Country country = _db.Countries .Include(c=>c.Cities.Select( cc => cc.People.Select( p => p.Addresses))) .Where(....)
Access to this extension method requires the directive
using System.Data.Entity;
这篇关于实体框架递归包括收集来自包括收集每个实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文