根据另一个属性(LINQ)计算属性值

use*_*173 1 c# linq

我有一个属性类:Row, Seat.例如,我们有以下数据:

Row Seat
1    1
1    2
1    3
2    4
2    5
Run Code Online (Sandbox Code Playgroud)

我想要Dictionary<int,int>包含Row作为键的返回,以及行中的座位数作为值.对于上面的例子,字典将包含两个记录:

Key Value
1    3
2    2
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?
谢谢.

L.B*_*L.B 8

list.GroupBy(x => x.Row)
    .ToDictionary(x => x.Key, x => x.Count());
Run Code Online (Sandbox Code Playgroud)