There are two linq querys in below, they return complete difference result, first query return 4 records second return 72 records. I think they are same. Who can explain why they return difference record set. Thanks for helping.
void Main()
{
var q1 = from c in Customers
where !c.Orders.Any(o => o.OrderDetails.Sum(od => od.UnitPrice * od.Quantity) < 1000)
select new {c.CustomerID, c.ContactName};
q1.Dump();
var q2 = from c in Customers
where c.Orders.Any(o => o.OrderDetails.Sum(od => od.Quantity * od.UnitPrice) >= 1000)
select new {c.CustomerID, c.ContactName};
q2.Dump();
}
In other words, imagine a customer who made one order of total price less than 1000, and another order of total price greater than 1000. Because of the smaller order, the customer record would not be included in the first result set, but because of the larger order, it would be included in the second result set.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.