如何使用LINQ
實現以下分組通過?與LINQ
我有一些C#對象(我寫他們爲JSON
爲了簡化只)
{ Name: A, Domain: a, SubDomain: 1}
{ Name: B, Domain: a, SubDomain: 2}
{ Name: C, Domain: b, SubDomain: 1}
{ Name: D, Domain: b, SubDomain: 2}
{ Name: E, Domain: c, SubDomain: 1}
我想收集這些:
{ Domain: a ,{{Name: A, SubDomain: 1}, {Name: B, SubDomain: 2}}
Domain: b ,{{Name: C, SubDomain: 1}, {Name: D, SubDomain: 2}}
Domain: c ,{{Name: E, SubDomain: 1}}
'的GroupBy(X => x.Domain)' – gdoron 2012-04-04 12:03:16
你試圖谷歌? [code.msdn](http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b) – stukselbax 2012-04-04 12:04:17