有許多看似相關的Linq問題,但是快速瀏覽內容似乎並不足以回答我的問題,足以讓我有限的智能掌握。使用Linq將列表拆分成集合
我們有一個名爲PropertyInteractions
的表,其中存儲了通過線程ID的線程消息,線程標識符是初始交互記錄的Id
。鑑於以下Linq查詢(它檢索與用戶有關的所有交互),我怎樣才能將interactions
分爲PropertyInteraction
列表,按Id
分組?
Dim interactions = (From interaction In propertyItem.PropertyInteractions _
Where (interaction.SenderId = CurrentUser.ID OrElse _
interaction.RecipientId = CurrentUser.ID) AndAlso _
interaction.InteractionType = InteractionType.ViewRequest _
Order By interaction.ThreadId _
Select interaction)
編輯:
由於喬恩的投入,這是我的時刻來到,儘管它可能會有所變動...
Dim interactions = _
(From interaction In propertyItem.PropertyInteractions _
Where (interaction.SenderId = CurrentUser.ID OrElse _
interaction.RecipientId = CurrentUser.ID) AndAlso _
interaction.InteractionType = InteractionType.ViewRequest _
Order By interaction.ThreadId _
Group interaction By interaction.ThreadId Into Group)
您的訂購現在有點怪......你爲什麼要下令分組查看'interaction.SendDate`命令的結果。那不計算... :) – 2011-02-07 12:21:01
剛纔已經很明顯。 ;)我試圖嘗試的順序已經變得無關緊要了,所以我可以對分組感到厭煩。 – 2011-02-07 12:31:49