Linq Where Clauses - Better to stack or combine?

Posted by burnt_hand on Stack Overflow See other posts from Stack Overflow or by burnt_hand
Published on 2010-03-24T08:42:24Z Indexed on 2010/03/24 8:43 UTC
Read the original article Hit count: 385

Filed under:
|

When writing a method chain for LINQ, I can do the Where statements one of two ways:

var blackOldCats = cats.Where(cat => cat.Age > 7 && cat.Colour == "noir" )

Or

var blackOldCats = cats.Where(cat => cat.Age > 7).Where(cat.Colour == "noir" )

Are there any benefits of one over the other?

Don't worry too much about the datatypes in this example, but if there are issues with datatypes, then that would be good to know too.

© Stack Overflow or respective owner

Related posts about linq-to-objects

Related posts about c#