Convert Linq ObjectQuery IQueryable to IEnumerable -
totally confused data types required here.
i have linq statement:
var feat = allcustomers .select(c => c.customerservices.selectmany(cs => cs.customerservicefeatures) .selectmany(csf => csf.configelements).where(ce => ce.name == "itemtype").select(ce => ce.value).distinct());
it returns required data, , vs tells me type being set as:
system.data.objects.objectquery<system.collections.generic.ienumerable<string>>
however want add data list of strings:
list<string> itemtypes = new list<string>(); itemtypes.addrange(feat);
but throws error:
argument 1: cannot convert 'system.linq.iqueryable<system.collections.generic.ienumerable<string>>' 'system.collections.generic.ienumerable<string>'
i can't find required syntax cast correct type. can help?
cheers, matt
compile-time error shows, feat
"collection of collection of string" (literally "iqueryable of ienumerable of string"). need generate flat collection.
feat.selectmany(x => x)
Comments
Post a Comment