Reputation: 6561
I have the following code which will find an error if results contains the key. It will then select the count of errors:
var foundError = results
.Where(e => e.PropertyValidationErrors.Keys.Contains(id))
.Select(e => e.PropertyValidationErrors[id]).ToList();
I want to instead find an error if the id is not found in the results. I'm not sure of the syntax. I want to do something like this:
// This is not correct, but similar to what I want to do
var foundError = results
.WhereNot(e => e.PropertyValidationErrors.Keys.Contains(id))
.Select(e => e.PropertyValidationErrors[id]).ToList();
Please advise on the syntax. Thanks
Upvotes: 0
Views: 43
Reputation: 3565
I think you can just do
var foundError = results
.Where(e => !e.PropertyValidationErrors.Keys.Contains(id))
.Select(e => e.PropertyValidationErrors).ToList();
and it will select all PropertyValidationErrors for objects that don't contain a propertyValidationError with the selected key.
Upvotes: 1