日期:2014-05-20 浏览次数:20873 次
var query=from t in db.tb_category
join o in db.tb_articleon t.Id equals o.categoryId into temp
from tt in temp.DefaultIfEmpty()
group tt by new { Name=tc.Name, Id=tc.Id } into g
select new { g.Key.Id, g.Key.Name,g.Count()};
var query=from tc in dbo.tb_category
join ta in dbo.tb_article on tc.Id equals ta.categoryId into leftGroup
from ta in leftGroup.DefaultIfEmpty()
group new {tc,ta} by new {tc.Name,tc.Id} into g
select new {g.Key.Id,g.Key.Name,articleTotal =g.Count()};