我收到错误
在当前未实现的数据库服务器端执行'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。
这有什么解决方案或解决方法吗?
答案 0 :(得分:1)
http://www.telerik.com/forums/server-side-currently-not-implemented
在第一次查询之后,将其转换为列表,然后运行子查询。
像这样:from t in dbContext.TrackerRecords.ToList()
然后,查询的其余部分。