I have this pseudo object
list<ListOfCars>{
list<ListOfParts>
}
I currently have this query
ListOfCars.Where(x => x.ListofParts.Any(y => y.PartIsDeleted == false));
On my investigation, it returns something if atleast 1 item satisfies the condition in the Any(y => y.PartIsDeleted == false).
My question is what is the syntax for something like this
SELECT * FROM ListOfCars cars WHERE cars.ListOfParts.PartIsDeleted = false
There are 3 easy combinations in using Any and All.
Be crystal clear which you do want.
At least one of ListofParts is not deleted.
ListOfCars.Where(x => x.ListofParts.Any(y => y.PartIsDeleted == false));
All of ListofParts are not deleted
ListOfCars.Where(x => x.ListofParts.All(y => y.PartIsDeleted == false));
None of ListofParts is deleted
ListOfCars.Where(x => x.ListofParts.Any(y => y.PartIsDeleted) == false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With