linqtosql,时间跨度,聚合..能做到吗



这能用linqtosql完成吗?

SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime
FROM Incidents
GROUP BY City
using System.Data.Linq.SqlClient;

db.Incidents
  .GroupBy(i => i.City)
  .Select(g => new
  {
    City = g.Key,
    DownTime = g.Sum(i => SqlMethods.DateDiffMinute(i.StartDate, i.Completed))
  });

是。您必须使用SqlMethods类。

http://msdn.microsoft.com/en-us/library/bb882657.aspx

相关内容

  • 没有找到相关文章

最新更新