tags:

views:

167

answers:

2

Can this be done w/ linqtosql?

SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP BY City

A: 

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))
  });
David B
+1  A: 

Yes. You have to use the SqlMethods class.

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

Darren Kopp