Should I use two “where” clauses or “&&” in my LINQ query?

后端 未结 4 851
[愿得一人]
[愿得一人] 2020-11-29 03:09

When writing a LINQ query with multiple \"and\" conditions, should I write a single where clause containing && or multiple where

4条回答
  •  天涯浪人
    2020-11-29 03:45

    This is mostly a personal style issue. Personally, as long as the where clause fits on one line, I group the clauses.

    Using multiple wheres will tend to be less performant because it requires an extra delegate invocation for every element that makes it that far. However it's likely to be an insignificant issue and should only be considered if a profiler shows it to be a problem.

提交回复
热议问题