这是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();
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();