且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

对连接表中的列求和,以使用linq to SQL获取计算值

更新时间:2023-01-20 19:41:54

var q = from c in customer
        join o in order on o.fk_custId equals c.custId
        join ol in orderLines on ol.fk_orderId equals o.orderId
        join fi in foodItem on fi.foodId equals ol.fk_foodId
      \\  where 
        group new { c, o, ol, fi }  into g
        select new 
        { 
           orderId= o.orderId,
           date = o.date, 
           Total = g.Sum(x => x.fi.price* x.ol.quantity),
           TotalPrice= g.Sum(x => x.ol.extraPrice + x.m.Total )
        };





表连接不是特定的。请修改,因为我举例。请尝试此查询。



Table Joins are not specific. Please modify, as i was giving example. Please try this query.