from component in Materials.OfType<Container>().Where(m => m.Active)join segmentFinancerating in segmentFinanceratingVIEw on component.ID equals segmentFinancerating.MaterialID into segmentFinanceratingGroupfrom segmentFinanceratingWithDefault in segmentFinanceratingGroup.DefaultIfEmpty()select new{ ID = component.ID,name = component.name,subType = component.SubType,size = component.Size,MaterialIDs = component.Materials.Select(x => x.ID),Brandnames = component.Brands.Select(x => x.name),Segmentratings = segmentFinanceratingWithDefault}
我有上面的liNQ to EntitIEs查询,它有一个left JOIN来获取给定组件的1个或多个段的评级值.
segmentFinancerating实体具有{MaterialID,SegmentID,rating,LowRated}属性
目前,结果未分组到相关组件,即Segmentratings属性不是segmentFinancerating对象的单个集合,而是我有多个数据行,每个数据行中包含1个segmentFinancerating对象.
我已经看到了一些使用x组进入z的例子但是我无法使它工作,可能是由于我需要的组件上的一些集合,我不确定.
如果这样做,任何帮助将不胜感激,谢谢.
解决方法 列表中的GroupBy不适合您?var List = (from component in Materials.OfType<Container>().Where(m => m.Active)join segmentFinancerating in segmentFinanceratingVIEw on component.ID equals segmentFinancerating.MaterialID into segmentFinanceratingGroupfrom segmentFinanceratingWithDefault in segmentFinanceratingGroup.DefaultIfEmpty()select new{ ID = component.ID,Segmentratings = segmentFinanceratingWithDefault}).ToList().GroupBy(s=> s.Segmentratings);总结
以上是内存溢出为你收集整理的c# – Linq to Entities左外连接分组为一个集合全部内容,希望文章能够帮你解决c# – Linq to Entities左外连接分组为一个集合所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)