SelectMany() Cannot Infer Type Argument — Why Not?

The type returned by the delegate you pass to SelectMany must be an IEnumerable<TResult>, but evidently, Office doesn’t implement that interface. It looks like you’ve simply confused SelectMany for the simple Select method.

  • SelectMany is for flattening multiple sets into a new set.
  • Select is for one-to-one mapping each element in a source set to a new set.

I think this is what you want:

foreach (var office in CurrentEmployee.EmployeeOffices.Select(eo => eo.Office))

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)