.net - EF 4 Filter sub collection -
im trying maingroups related entities. , filter buildingpartdata collection without affecting of other entities. have pretty tried every thing can think of no luck.
test.contextoptions.lazyloadingenabled = false; var buildingpartmaingroups = (from buildingpartmaingroup in test.buildingpartmaingroup buildingpartsubgroup in buildingpartmaingroup.buildingpartsubgroup buildingpart in buildingpartsubgroup.buildingpart buildingpartdata in buildingpart.buildingpartdata buildingpartdata.statuspendingapprove == true //let buildingpartdata = buildingpartmaingroup.buildingpartsubgroup.where(x => x.buildingpart.any(o => o.buildingpartdata.any(y => y.statuspendingapprove == true))) select new { buildingpartmaingroups = buildingpartmaingroup, buildingpartdatas = buildingpartdata }).tolist().select(c => c.buildingpartmaingroups); foreach (var bb in buildingpartmaingroups) { foreach(var tt in bb.buildingpartsubgroup) { foreach (var oo in tt.buildingpart) { foreach (var ww in oo.buildingpartdata) { bool tes4t = ww.statuspendingapprove; } } } }
here model
http://mimo-design.com/model.png
cant insert images yet..
var buildingpartmaingroups = test.buildingpartmaingroup.include("buildingpartsubgroup.buildingpart.buildingpartdata"). where(bpmg => bpmg.buildingpartsubgroup. any(o => o.buildingpart. any(x => x.buildingpartdata. any(u => u.statuspendingapprove == true))));
it filtered buildingpartmaingroup entity. have buildingpartmaingroup entities, condition / filter on buildingpartdata
did think of like:
context.buildingpartmaingroup .inlcude("buildingpartsubgroups.buildingparts.buildingpartdata") .where<buildingpartmaingroup>(bpmg => bpmg.buildingpartsubgroups.any<buildingpartsubgroup>(etc...
Comments
Post a Comment