Thank you for the provided project.
The reason for the error you are experiencing most probably lies within the combination of the complexity of the query and the projection in non persistent type.
As a workaround you could consider splitting the query into two parts.
var trackedRecords = (from t
DateTime(2014, 2, 1) && t.Date <=
DateTime(2014, 3, 21)
orderby t.Date descending
var tripDataModels = (from r
group r by r.Date.Date
Day = g.Key,
Trips = (from x
group x by x.Date.Hour
where gj.Max(m => m.Speed) > 0
let AvgSpd = gj.Average(m => m.Speed)
MinSpeed = gj.Min(m => m.Speed),
MaxSpeed = gj.Max(m => m.Speed),
AvgSpeed = AvgSpd > 0 ? Math.Round(AvgSpd, 2, MidpointRounding.AwayFromZero) : 0,
DateTime(g.Key.Year, g.Key.Month, g.Key.Day, gj.Key, 0, 0)
The first part
retrieves the required TrackRecord objects and then the second part
is executed in memory. As in your original query most of the filtering was done prior to the projection, this approach should not introduce any performance issue compared to your original query. Another thing you may notice is that the initial grouping from your original query is now moved to the second part. This is done in order to avoid the N+1 problem.
I hope this helps. Should you have additional questions, feel free to post in our forums again.
OpenAccess ORM is now Telerik Data Access
. For more information on the new names, please, check out the Telerik Product Map