2

アイテムの大きなテーブルがあり、カテゴリ、年、月の順に整理する必要があります。

アイテムには、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

ありがとう

4

1 に答える 1

3

これを読んだ後(このトピックに関する詳細情報もあります):

http://msdn.microsoft.com/en-us/vbasic/bb738024.aspx

私は思いついた:

Dim Items = From Item In DB.Items _
  Group Item By CatID = Item.CatID Into Group Select CatID, _
  YearGroups = From y In Group _
    Group y By YearKey = y.PubDate.Value.Year Into YearGroup = Group _
    Select Year = YearKey, _
    MonthGroups = From m In YearGroup _
      Group m By MonthKey = m.PubDate.Value.Month Into MonthGroup = Group _
      Select Month = MonthKey, MonthItems = MonthGroup
于 2009-07-07T22:06:39.857 に答える