c# - SelectMany() Cannot Infer Type Argument -- Why Not? -
i have employee
table , office
table. these joined in many-to-many relationship via employeeoffices
table.
i'd list of offices particular employee (currentemployee
) associated with.
i thought this:
foreach (var office in currentemployee.employeeoffices.selectmany(eo => eo.office)) ;
but gives me error:
the type arguments method 'system.linq.enumerable.selectmany(system.collections.generic.ienumerable, system.func>)' cannot inferred usage. try specifying type arguments explicitly.
i understand add type arguments. intellisense recognizes eo.office
of type office. why isn't clear compiler?
the type returned delegate pass selectmany
must ienumerable<tresult>
, evidently, office
doesn't implement interface. looks you've confused selectmany
simple select
method.
selectmany
flattening multiple sets new set.select
one-to-one mapping each element in source set new set.
i think want:
foreach (var office in currentemployee.employeeoffices.select(eo => eo.office))
Comments
Post a Comment