Marius Vasile

Marius Vasile

  • 594
  • 1.9k
  • 146.5k

asp.net core distinct selectlistitem not working properly

Jun 7 2021 7:15 AM

I am trying to list distinct values in a SelectListItem but it is not working. Any ideeas?

HazardSourceList = await _context.RiskAssessmentsMain.Where(s => s.OrgID == orgid).Select(s =>
                                                    new SelectListItem
                                                    {

                                                        Value = s.IdRA.ToString(),
                                                        Text = s.HazSource

                                                    }).Distinct().ToListAsync();

 


Answers (3)