Linq查询,其中嵌套子对象,实体框架
我有以下实体框架模型,我正在检索一些营销活动实体。营销活动可以有多个组,每个组可以有多个门店。 我需要能够做的是为特定StoreId选择所有营销活动。我知道如何查询单个嵌套实体,例如Linq查询,其中嵌套子对象,实体框架,linq,entity-framework,nested,where-clause,Linq,Entity Framework,Nested,Where Clause,我有以下实体框架模型,我正在检索一些营销活动实体。营销活动可以有多个组,每个组可以有多个门店。 我需要能够做的是为特定StoreId选择所有营销活动。我知道如何查询单个嵌套实体,例如Groups.SelectMany(n=>n.StoresInGroups)。其中(s=>s.StoreId==2)但不确定如何将其嵌套到足够深的位置以获得所需的结果 编辑:更清晰的图片 var context = new context(); // init your context here var query
Groups.SelectMany(n=>n.StoresInGroups)。其中(s=>s.StoreId==2)代码>但不确定如何将其嵌套到足够深的位置以获得所需的结果
编辑:更清晰的图片
var context = new context(); // init your context here
var query =
from sig in context.Store.Single(p=>p.StoreId = 2).StoresInGroup //filter out by particular toreId
from grp in sig.Group.Marketing_Groups
from mc in grp.MarketingCampaign
select mc;