如何将以下SQL查询转换为lambda表达式?
select MAX(ID),ProcessInstanceID from tblKGWorks
where FormID = 2598 and FormTypeID =2306
group by ProcessInstanceID
答案 0 :(得分:0)
试一试:
var qry = tblKGWorks
.Where(gk=>gk.FormID == 2598 && gk.FormTypeID == 2306)
.GroupBy(x=>x.ProcessInstanceID)
.Select(grp=>new{ID = grp.Max(a=>a.ID), ProcessInstanceID = grp.Key});
更多信息:101 Linq Samples