Resharper: Possible Multiple Enumeration of IEnumerable

I don’t know exactly what your properties really is here – but if it’s essentially representing an unmaterialized database query, then your if statement will perform three queries.

I suspect it would be better to do:

string[] propertiesToFind = { "Property1", "Property2", "Property3" };
if (properties.Any(x => propertiesToFind.Contains(x))
{
     ...
}

That will logically only iterate over the sequence once – and if there’s a database query involved, it may well be able to just use a SQL “IN” clause to do it all in the database in a single query.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)