Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想总结一下“房间”和“目标代码”相等的“计数”字段。
有任何想法吗?
我不知道您的上下文是如何设置的,表名是什么以及回答您的问题所必需的其他十几个东西,但它肯定会使用GroupByLINQ 方法,例如:
GroupBy
var results = db.TableName.GroupBy(x => new { x.Room, x.ObjectCode }) .Select(g => new { g.Key.Room, g.Key.ObjectCode, Count = g.Sum(x => x.Code) }) .ToList();