1

Find all customers whose purchase is less than 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))), }; 

I have solved it but if I want to access Order table information then how can I access...

For your information I am binding customer to grid....so I can not use for each

1
  • customer has many orders which order's information u want to access. Furthermore, How collection of anonymous objects is supposed to populate a grid? Commented Sep 11, 2011 at 10:40

1 Answer 1

1

If I understood correctly what you want, you can try this:

 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, }; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.