var results = from customer in customers where customer.State == "WA" let custOrders = (from order in orders where customer.ID == order.ID select new ...
var results = from customer in customers where customer.State == "WA" let custOrders = (from order in orders where customer.ID == order.ID select new { order.Date, order.Amount }) where custOrders.Count(co => co.Amount >= 10 && co.Date >= DateTime.Now.AddMonths(−10)) >= 3 select new { customer.Name, customer.Age };
下麵另附上一條分頁的linq語句:
var productList=(from prod in db.Products
where prod.Type="零食" orderby prod.datatime select u).Skip(PageSize*(PageNum-1)).Take(PageSize);