Ir al contenido

Linq count misuse (ARCH902)

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

Key dotnet.linq.linq-count-misuse · Severity info · Category linq

Using Count() > 0 just to check for existence counts the whole collection; Any() stops at the first element.

if (users.Count() > 0)
{
Process(users);
}
if (users.Any())
{
Process(users);
}

Use Any() for existence checks.