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;
精彩评论