我有一个很大的项目表,我需要按类别组织它们,然后按年,然后按月。
项目具有 CategoryID 和 Dated 属性。
我做到了这一点:
Dim Items = From Item In DB.Items _
Group By CategoryID = Item.CategoryID _
Into Categories = Group _
Order By CategoryID
但我把:
Group By Year = Year(Item.Dated)
和
Group By Month = Month(Item.Dated)
最终结果应该是这样的:
For Each Category in Categories
For Each Year in Category.Years
For Each Month in Year.Months
For Each Item in Month.Items
Next
Next
Next
Next
谢谢