LINQ to Entities group-by failure using .date

Use the EntityFunctions.TruncateTime method:

var myQuery = from p in dbContext.Trends
          group p by EntityFunctions.TruncateTime(p.UpdateDateTime) into g
          select new { k = g.Key, ud = g.Max(p => p.Amount) };

Leave a Comment