I have a fairly complex LINQ query that joins several tables, and selects a new anonymous type that is three IEnumerable's {Users, JobProviders, Jobs}
. It returns an IQueryable to maintain deferred execution, which eliminates DistintBy from this question.
One of the columns is a rank, and I need to make sure that only the record with the lowest rank for each job (another column, many jobs will get selected) gets selected. Distinct doesn't work because the rank will obviously make the row unique.
I thought the group clause might help this, but it changes the return type to IGrouping. I don't fully understand how group works, so I may be wrong, but it looks it wont work. Is there any way to say for each job, take only the lowest rank?
something like
let jobRank = JobProvider.Rank
...where min(rank)