I need to check if all definitions contains some specific data. It works fine except the case when GroupBy returns empty collection.
var exist = dbContext.Definitions
.Where(x => propertyTypeIds.Contains(x.PropertyTypeId) && x.CountryId == countryId)
.GroupBy(x => x.PropertyTypeId)
.All(...some condition...);
How to rewrite this so All would return false on empty collection?
UPDATE: It is a LINQ to SQL and I wanted to execute this in single call.
UPDATE2: I think this works:
var exist = dbContext.Definitions
.Where(x => propertyTypeIds.Contains(x.PropertyTypeId) && x.CountryId == countryId)
.GroupBy(x => x.PropertyTypeId)
.Count(x => x
.All(...some condition...)) == propertyTypeIds.Count;