这能用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