查找购买量低于10000的所有客户
var Customer = from c in _NorthWindDataContext.Customers
join o in _NorthWindDataContext.Orders on c.CustomerID equals o.CustomerID
group c by c.CustomerID into CutGroup
where CutGroup.Sum(tab => tab.Orders.Sum(t => t.Order_Details.Sum(t1 => t1.Quantity * t1.Quantity))) < 10000
select new
{
CustomerID = CutGroup.Key,
Total = CutGroup.Sum(tab => tab.Orders.Sum(t => t.Order_Details.Sum(t1 => t1.Quantity * t1.Quantity))),
};
我已经解决了,但如果我想访问Order
表格信息,那么我该如何访问...
为了您的信息,我将客户绑定到网格....所以我不能用于每个
答案 0 :(得分:1)
如果我理解你想要的东西,你可以试试这个:
var Customer = from c in _NorthWindDataContext.Customers
join o in _NorthWindDataContext.Orders on c.CustomerID equals o.CustomerID
group c by c.CustomerID into CutGroup
where CutGroup.Sum(tab => tab.Orders.Sum(t => t.Order_Details.Sum(t1 => t1.Quantity * t1.Quantity))) < 10000
select new
{
CustomerID = CutGroup.Key,
Total = CutGroup.Sum(tab => tab.Orders.Sum(t => t.Order_Details.Sum(t1 => t1.Quantity * t1.Quantity))),
Orders = from os in _NorthWindDataContext.Orders where os.CustomerID == CutGroup.Key select os,
};