开发者

Converting SQL into LINQ To SQL statement

Can someone please help convert the following into LINQ To SQL query?

select * from projects pr
where pr.Active<>0 
AND CapturedDocumentType=2 
AND SubmissionReminderTypeID > 0 
AND pr.ProjectID In(SELECT Max(wpr.ProjectID) as ProjID 
    开发者_开发技巧                FROM Projects wpr 
                    where wpr.Active<>0 
                    AND wpr.CapturedDocumentType=2 
                    AND wpr.SubmissionReminderTypeID > 0
                    group by wpr.EmployeeID)


try this

var result = from pr in dc.Projects
             where 
                (from wpr in dc.Projects
                 where wpr.Active && 
                       wpr.CapturedDocumentType == 2 && 
                       wpr.SubmissionReminderTyepID > 0
                 group wpr by wpr.EmployeeID into gpr
                 select gpr.Max(x => x.ProjectID)).Contains(pr.ProjectID)
             select pr;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜