首页 > 解决方案 > c# datagridView , 显示总价

问题描述

在此处输入图像描述

嗨,我想生成每个售出产品的总价格。我的桌子就像你在附图中看到的那样它在没有总价的情况下工作。我的意思是仅使用 prtoductType 和 Totalsold 才能正常工作。但我想显示这种产品的总价。我的代码如下但不工作,请帮忙!

var result = (from s in db.SaleDetails
              join p in db.Product on s.ProductId equals p.ProductId
              group s by p.Description into g
              select new
              {
                ProductType = g.Key,
                TolatlSold = g.Count(),
                TotalPrice = g.Count() *//Times what ?? I tried g.Count()*p.price but I can't
              }).ToList();

标签: c#datagridviewsum

解决方案


推荐阅读