Linq分组问题,求救啊~
var mul = (from a in db.Bus_PowerTree
join b in db.Bus_Popedom
on a.Code equals b.Code
into joinTable
where a.Id > 0
//from b in joinTable.DefaultIfEmpty()
group a by a.ParentId //这里老是错,我不知道到底少了什么~
select new Bizlink.Models.Dayshouse.Message.PowerCommentsInfo()
{Id = a.Id,Name = a.Name,ParentId = a.ParentId });
model.ItemList = mul.ToList();
------最佳解决方案--------------------你要按照LINQ的语法来写才行:
var mul = (from a in db.Bus_PowerTree
where a.Id > 0
join b in db.Bus_Popedom
on a.Code equals b.Code
into joinTable
from b in joinTable.DefaultIfEmpty()
group a by a.ParentId into g
select new Bizlink.Models.Dayshouse.Message.PowerCommentsInfo()
{Id = g.First().Id,Name = g.First().Name,ParentId = g.Key });
------其他解决方案--------------------从你的查询语句来看,最后的查询结果和db.Bus_Popedom 根本就没有关系啊
更别说用什么LEFT JOIN语句了