LINQ: Group by month and year within a datetime field

前端 未结 5 1146
轻奢々
轻奢々 2020-12-08 00:38

I have a table with a datetime field. I want to retrieve a result set grouped by the month/year combination and the number of records that appear within that month/year. H

5条回答
  •  抹茶落季
    2020-12-08 01:02

    This Site has an example that should fill your need.

    This is the basic syntax:

    from o in yg
    group o by o.OrderDate.Month into mg
    select new { Month = mg.Key, Orders = mg }
    

提交回复
热议问题