我有以下实体框架模型,正在检索许多marketing_campaign实体。市场营销活动可以有多个组,每个组可以有多个商店。
我需要做的是为特定的StoreId选择所有营销活动。我知道如何对单个嵌套实体进行查询,例如,Groups.SelectMany(n => n.StoresInGroups).Where(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;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句