I'm getting information from a table and filling a DropDownList
, but I have a lot of information repeated and would like to group the values so they do not repeat in DropDownList
.
Example information I'm capturing.
Cidade1
Cidade2
Cidade1
Cidade1
Cidade3
I would like the DropDownList to only receive Cidade1
, Cidade2
and Cidade3
without repetition.
In Controller I am using the following statement, but I did not succeed:
List<Empresa> items = db.Empresa.OrderBy(x => x.Cidade).ThenBy(x => x.Cidade).ToList();