Reputation: 8674
In the following function I get an error when I try to return a value saying:
Cannot convert
System.Linq.IQueryable<System.Collections.Generic.IEnumerable<string>>
to return typeSystem.Collections.Generic.IEnumerable<string>
public IEnumerable<string> GetModuleKindPropertyNames(long moduleKindId)
{
var configurationId = GetModuleKindPertypeConfigurationId(moduleKindId);
var propertyNames = _dbSis.ModuleKinds
.Where(t => t.PerTypeConfigurationId == configurationId)
.Select(x => x.PerTypeConfiguration.Properties
.Select(z => z.Name));
return propertyNames; //red line below property names
}
How can I solve this issue?
Upvotes: 0
Views: 283
Reputation: 59923
It looks like you want to select items from a collection within a collection and flatten the result into a single sequence.
Conceptually, something like:
If that's the case, you're looking for the SelectMany method:
var propertyNames = _dbSis.ModuleKinds
.Where(t => t.PerTypeConfigurationId == configurationId)
.SelectMany(x => x.PerTypeConfiguration.Properties)
.Select(z => z.Name);
Upvotes: 1