1

I am getting the error

Execution of 'System.Linq.Enumerable:GroupBy(IEnumerable`1,Func`2)' on the database server side currently not implemented.

when I execute the following query

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)
         })
   }

I tried the query in linqtosql and working fine but I need to use Telerik OpenAccess.

Is there any solution or workaround this?

Paul Turner
  • 38,949
  • 15
  • 102
  • 166
Muhammad Alaa
  • 608
  • 1
  • 10
  • 15
  • can you group in memory, not at the server side? – Ilya Ivanov Mar 06 '14 at 10:00
  • Why to group in memory LinqToSql can group at server. why openAccess can not? – Muhammad Alaa Mar 06 '14 at 10:10
  • the error message leads me to think that linq group by hasn't been implemented in OpenAccess. And, assuming that it has own implementation (not using LinqToSql behind it), it is make sense you can use group by with LinqToSql but not with OpenAccess. **BUT**, after looking at [this forum discussion](http://www.telerik.com/forums/is-group-by-supported), I think group by should've been implemented in OpenAccess. Better try to post the question in that forum. – har07 Mar 06 '14 at 10:35

1 Answers1

1

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

After the first query, convert it to a list, then run the subquery.

like this:

from t in dbContext.TrackerRecords.ToList()

Then, the rest of your query.

seabass2020
  • 1,093
  • 14
  • 12
  • If the query really can't be executed on the server side, then you shouldn't use `ToList` to evaluate it using Linq to objects, you should use `AsEnumerable`. – Servy Sep 30 '14 at 19:52
  • If you use `AsEnumerable` is it still executed on the database? – Henk Jansen Jan 06 '16 at 08:17