我试图用LINQ语法编写以下查询:
SELECT Patient.PatientIDA, MAX(TxFieldPoint.EditDttm) AS Expr1
FROM Patient INNER JOIN
TxSite ON Patient.PatientIDA = TxSite.PatientIDA INNER JOIN
TxField ON TxSite.SiteId = TxField.SiteId INNER JOIN
TxFieldPoint ON TxField.FldId = TxFieldPoint.FldId
GROUP BY Patient.PatientIDA
ORDER BY Patient.PatientIDA
我正在谈论这个:
var PtsList = from pt in dc.Patient
join site in dc.TxSite on pt.PatientIDA equals site.PatientIDA
join fld in dc.TxField on site.SiteId equals fld.SiteId
join fldpnt in dc.TxFieldPoint on fld.FldId equals fldpnt.FldId
group new { pt, fldpnt } by new { fldpnt.EditDttm } into pt_fldpnt
select new cPtData
{
pt_name = pt_fldpnt.FirstOrDefault().pt.LastName,
pt_firstname = pt_fldpnt.FirstOrDefault().pt.FirstName,
pt_hospitalID = pt_fldpnt.FirstOrDefault().pt.PatientIDA,
chart_lasteditdttm = pt_fldpnt.Max(m => m.fldpnt.EditDttm).Value.Date,
};
根据我在本网站上阅读的其他帖子。这是行不通的。非常感谢帮助。