I'm trying to run the code below, but I'm getting an error on the first SelectMany
statement: "The type arguments for method 'IEnumerable<TResult> System.Linq.Enumerable.SelectMany...'
cannot be inferred from the usage. Try specifying the type arguments explicitly".
Company has a list of Employments
, I want to get a list with all employments
of the company called "Company1"
, and after I need to filter with the employee is currently working (when EndDate
is null) and return a list only with their names.
I need to do it using Linq Queries.
var employees = FindAllCompanies()
.Where(x => x.Name == "Company1")
.SelectMany(x => x.Employments)
.Select(x => x.EmploymentEndDate == null)
.SelectMany(x.Name);