首页 新闻 搜索 专区 学院

这个sql语句该怎么写成linq或lambda的,求指导

0
[已解决问题] 解决于 2018-09-19 18:07

这是sql语句:
select COUNT(c.CreateId) as aa,i.Name from CDM c
left join User u on c.CreateId=u.Id
left join Info i on u.IId=i.Id
group by c.CreateId,i.Name

想写成这样的:
CurrentContext.Set<CDM>()
.Join(CurrentContext.Set<User>(), i => i.CreateId, c => c.Id, (i, c) => new { i, c })
.Join(CurrentContext.Set<Info>(), a => a.c.IId, b => b.Id, (a, b) => new { a, b })
.Where(m => m.a.c.Isdelete == 0 &&m.b.Isdelete==0&&m.a.i.Isdelete==0&& m.a.i.ThisDate > sDate && m.a.i.ThisDate < eDate)
.Select(m => new { m.a.i.ThisDate,m.a.i.CreateId,m.b.Name })
.GroupBy(m=>new { m.CreateId, m.Name })
.ToList();

xingcs的主页 xingcs | 初学一级 | 园豆:4
提问于:2018-09-19 10:40
< >
分享
最佳答案
0

List<CDM> cdm= (from c in this.Entities

join u in this.Context.Set<User>() on c.CreateId equals u.id

join i in this.Context.Set<Info >() on u.id equals i.id

group by c.CreateId,i.Name

select c.CreateId.count(),i.name).ToList();

奖励园豆:5
徒然喜欢你 | 小虾三级 |园豆:1646 | 2018-09-19 17:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册