How to use Linq group a order list by Date

Posted by Daoming Yang on Stack Overflow See other posts from Stack Overflow or by Daoming Yang
Published on 2010-04-09T10:46:25Z Indexed on 2010/04/09 10:53 UTC
Read the original article Hit count: 377

Filed under:
|

I have a order list and want to group them by the created date.

Each order's created datetime will be like "2010-03-13 11:17:16.000"

How can I make them only group by date like "2010-03-13"?

 var items = orderList.GroupBy(t => t.DateCreated)
 .Select(g => new Order()
 {
     DateCreated = g.Key

 })
 .OrderByDescending(x => x.OrderID).ToList();

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ