我是LINQ的新手。我堅持一個非常愚蠢的問題LINQ中的聚合
Name Subjects Role
---- -------- --------
A Math Student
A English Student
B Math Student
B English Student
C Math Student
C Math Admin
我需要得到作爲
Name Subjects Role
---- -------- --------
A Math, English Student
B Math, English Student
C Math Student
C Math Admin
我很困惑,如何去了解這個問題。這在SQL中很簡單,我可以通過函數來執行groupby子句並通過逗號分隔值。
有人可以幫我嗎?
編輯:三列來自3個不同的來源。我更新了結果表。感謝您的幫助!
如果角色不同,那麼? – whihathac 2011-12-21 12:06:02
你需要在多列上做一個「GroupBy」。我已經更新了代碼,請現在檢查 – 2011-12-21 12:23:41
謝謝@Abdul。我正在使用LINQ to Entity,當我在LINQ PAD上執行時遇到此錯誤 NotSupportedException:LINQ to Entities無法識別方法'System.String Aggregate [String,String](System.Collections.Generic.IEnumerable' 1 [System.String],System.String,System.Func'3 [System.String,System.String,System.String])'方法,並且此方法不能轉換爲存儲表達式。 – whihathac 2011-12-22 11:16:16