var j=from o in Orders join OT in OrderDetails on o.OrderId equals OT.OrderId group OT.ProductId by o.OrderId into g select new{OrderId=g.Key,ProductId=g};The class Orders Contains TotalPrice. I want to retrieve it, but i get error,I tried like thisvar j=from o in Orders join OT in OrderDetails on o.OrderId equals OT.OrderId group OT.ProductId by o.OrderId into g select new{OrderId=g.Key,ProductId=g,TotalPrice=o.TotalPrice};It shows an error the term 'o' does not exist, pls help 解决方案 HiI am not sure if you want the total price for each order or if you want the sum of all the orders.If you want the TotalPrice per row all you should need is:var results = (from i in yourCollection group g by i.Column into g select new { ColumnName = o.Column, ColumnTotal = o.Column, }).ToList();Else if you want the sum of all orders try:var results = (from i in yourCollection group g by i.Column into g select new { ColumnName = i.Column, ColumnTotal = i.Sum(x => x.Value) }).ToList();Let me know how you get on. 这篇关于如何在LInq中检索Total的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-18 22:26