LINQ的INNER,GROUP BY语法

LINQ的语法:


var reportList = from sr in context.SYS_REPORT
     join srf in context.SYS_REPORT_FORM
     on sr.REPORT_ID equals srf.REPORT_ID
     group sr by new { sr.REPORT_ID, sr.NAME } into p
     orderby p.FirstOrDefault().ENAME
     select new { p.FirstOrDefault().REPORT_ID, p.FirstOrDefault().NAME };

对待的SQL语法:


SELECT SR.REPORT_ID, SR.NAME FROM SYS_REPORT SR
INNER JOIN SYS_REPORT_FORM SRF ON SR.REPORT_ID=SRF.REPORT_ID
GROUP BY SR.REPORT_ID, SR.NAME

发表评论