saikishore madugula saikishore madugula - 3 months ago 11
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.
[male
female
male
male
].
my project is visual studio-angularJS-web api-linq-sql-entity framework.

Jay Jay
Answer

something like

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