开发者

Converting SQL into LINQ To SQL statement

开发者 https://www.devze.com 2023-02-22 03:24 出处:网络
Can someone please help convert the following into LINQ To SQL query? select * from projects pr where pr.Active<>0

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

精彩评论

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