So I have the following code:
var itemsGrouped = this.Errors.GroupBy(x => x.UniqueName).AsEnumerable();
var hasErrors = !itemsGrouped.Any((f) =>
{
var errorCount = f.ToArray()
.Where(x => x.ErrorCount.HasValue)
.Count(x => x.ErrorCount.Value > 0);
return errorCount > 2;
});
and now I want to retrieve the individual items that matched the .Any() query. How do I get only matching items?
You can't directly, using the
Any()
function (it just returns abool
), but the.Where()
function will return a filteredIEnumerable<T>
which also has theAny()
function.So something like: