1

我收到错误

目前未在数据库服务器端执行“System.Linq.Enumerable:GroupBy(IEnumerable`1,Func`2)”。

当我执行以下查询时

from t in dbContext.TrackerRecords
   where t.DeviceSerial.Value.Equals(deviceSerial) &&
   t.Date.Value >= fromDate && t.Date.Value <= toDate
   orderby t.Date.Value descending
   group t by t.Date.Value.Date into g
   select new TripDataModel
   {
      Day = g.Key,
      Trips = (from x in g
         group x by x.Date.Value.Hour into gj
         where gj.Max(m => m.Speed.Value) > 0
         let AvgSpd = gj.Average(m => m.Speed.Value)
         select new TripModel
         {
            MinSpeed = gj.Min(m => m.Speed.Value),
            MaxSpeed = gj.Max(m => m.Speed.Value),
            AvgSpeed = AvgSpd > 0 
                ? Math.Round(AvgSpd, 2, MidpointRounding.AwayFromZero) 
                : 0,
            FromHour = new DateTime(g.Key.Year, g.Key.Month, g.Key.Day, gj.Key, 0, 0)
         })
   }

我在 linqtosql 中尝试了查询并且工作正常,但我需要使用 Telerik OpenAccess。

有什么解决方案或解决方法吗?

4

1 回答 1

1

http://www.telerik.com/forums/server-side-currently-not-implemented

在第一个查询之后,将其转换为列表,然后运行子查询。

像这样:

from t in dbContext.TrackerRecords.ToList()

然后,其余的查询。

于 2014-09-30T19:49:09.970 回答