Ir al contenido

Combine linq methods (ARCH605)

Esta página aún no está disponible en tu idioma.

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.