Zum Inhalt springen

Combine linq methods (ARCH605)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key dotnet.performance.combine-linq-methods · Severity info · Category performance · Principle Kiss

Instead of separate calls like Where then First, putting the predicate into First(...) scans the collection in a single pass.

var first = items
.Where(i => i.IsActive)
.First();
var first = items
.First(i => i.IsActive);

Combine filter and selection predicates into one LINQ call.