-1

I'm trying to remove the repeated course from the linq query below. When this query returns it returns multiples of the same course(s) but I would like for it to return unique courses. Can I use a hashset to make this list unique? Thanks for any help!

 foreach (var course in Model.Assignments
                             .Select((x, y) => new { Data = x, Index = y })
                             .Where(x => x.Data.Ids == listOfIds[i]))
 { 
    // code here 
 }
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
CloudyKooper
  • 727
  • 3
  • 19
  • 47

1 Answers1

0

I'm not sure that understand you in 100 percent, but if you have any class you can override methods: Equals and GetHashCode, then you can use Distinct() for query.

look here

Community
  • 1
  • 1
Marek Woźniak
  • 1,766
  • 16
  • 34