saikishore madugula saikishore madugula - 1 year ago 52
C# Question

How to avoid the duplicates in drop-down list by using linq?

I am using linq to write the query, whenever I am creating a new entry in a form,gender drop down list is generating duplicates in that list.if i create 2 new entries 2 options like this.
my project is visual studio-angularJS-web api-linq-sql-entity framework.

Jay Jay
Answer Source

something like

var filteredList = originalList
  .GroupBy(x => x.Gender)
  .Select(group => group.First());