I have a linq statement that looks like this:
if(items.Any(x => x.CustomerID == 4))
{
}
however, I want to find an object in my list of items that not only contains the customerID of 4 but also a designID of 6.
I know I can do this:
if(items.Any(x => x.CustomerID == 4) && items.Any(x => x.DesignID == 6))
{
}
but this may not work since I need to find the same object that has both these values (this would check individually if these exist). Is there a way to combine these?
You can combine two conditions like x.CustomerID == 4 && x.DesignID == 6
if(items.Any(x => x.CustomerID == 4 && x.DesignID == 6))
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