This question is locked. New answers and comments are not allowed.
Good day all
I am trying to create a pulldown with all distinct cities from a table. I use this code below.
Any idea why the .Distinct() is not having any effect, and how I would have to create the statement?
(I am NOT getting an error. Simply all cities not filtered distinct)
Markus
I am trying to create a pulldown with all distinct cities from a table. I use this code below.
Any idea why the .Distinct() is not having any effect, and how I would have to create the statement?
(I am NOT getting an error. Simply all cities not filtered distinct)
using
(EntitiesModel dbContext =
new
EntitiesModel())
{
List<T_user> FirmenNachOrt = (from a
in
dbContext.T_users
where a.User_benutzung ==
"Firma"
&& a.User_freischaltung ==
false
orderby a.User_ort
select a).Distinct().ToList();
rddl_firmen_nach_ort.DataSource = FirmenNachOrt;
rddl_firmen_nach_ort.DataTextField =
"user_ort"
;
rddl_firmen_nach_ort.DataValueField =
"user_ort"
;
rddl_firmen_nach_ort.DataBind();
rddl_firmen_nach_ort.Items.Insert(0,
new
DropDownListItem(
"Nach Ort suchen"
));
}
Markus