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.
嗨,我有一个表,可以跟踪几名员工进行的几笔交易,这些是字段,同一个员工可能已经做了几笔交易我如何编写一个 linq 查询来获取包含每个员工的总交易细节的记录?
结果应具有唯一的员工 ID,其中包含总待处理金额和总收据金额
EmployeeID|PendingAmount|RecieptAmount
对记录进行分组EmployeeID,然后计算每个员工组所需的所有内容:
EmployeeID
from e in db.Employess group e by e.EmployeeID into g select new { EmployeeID = g.Key, PendingAmount = g.Sum(x => x.PendingAmount), // total pending amount RecieptAmount = g.Sum(x => x.RecieptAmount) // total reciept amount }