My application is showing this error below:
Data binding directly to a store query (DbSet, DbQuery, DbSqlQuery) is not supported
Due to the fact that I am trying to bind my drop down control to this LINQ statement. Check below for my code;
using (AdventureWorksEntities dw = new AdventureWorksEntities())
{
ddlCon.DataSource = (from em in dw.Employees
select new { em.Title, em.EmployeeID }).Distinct().OrderBy(name => name);
;
ddlCon.DataTextField = "Title";
ddlCon.DataValueField = "EmployeeID";
ddlCon.DataBind();
}
NB: Please explain well in your answers why this error and the solution to it.