c# - LINQ to Entities group-by failure using .date -
i trying linq group on date part of datetime field.
this linq statement works groups date , time.
var myquery = p in dbcontext.trends           group p p.updatedatetime g           select new { k = g.key, ud = g.max(p => p.amount) }; when run statement group date following error
var myquery = p in dbcontext.trends           group p p.updatedatetime.date g   //added .date on line           select new { k = g.key, ud = g.max(p => p.amount) }; the specified type member 'date' not supported in linq entities. initializers, entity members, , entity navigation properties supported.
how can group date , not date , time?
use entityfunctions.truncatetime method:
var myquery = p in dbcontext.trends           group p entityfunctions.truncatetime(p.updatedatetime) g           select new { k = g.key, ud = g.max(p => p.amount) }; 
Comments
Post a Comment