Home > Net >  GroupBy with IQueryable
GroupBy with IQueryable

Time:12-29

I have a database with 3 Columns (Energy, Power, TIme(it contains and integer with the timestamp).

I already exerted 200 rows of this database in an IQueryable called "todayPower". Now i want to group these lines to Minutes, with the following code. I get the error

enter image description here

Code here:

 var todayPower = _context.Mains.Where(x => x.Time >= beginning
                                         && x.Time <= end);
var groupedPower = todayPower.GroupBy(Items => Items.Time.Minutes);

What should I do?

CodePudding user response:

You can fix it changing to a list:

 var todayPower = _context.Mains.Where(x => x.Time >= beginning
                                     && x.Time <= end).ToList();
 var groupedPower = todayPower.GroupBy(Items => Items.Time.Minutes);

I was getting the error: client side GroupBy not supported, so I fixed it like that

  • Related