Hi all.
I am not expert in ASP so i would be appreciated for the help. Issue connected to Entity FW, ListView Control, its Datasource and type convertion.
I have the following LINQ query :
RoutesEntities routesModel = new RoutesEntities();
LocalesEntities localesModel = new LocalesEntities();
ObjectQuery routesQuery = (ObjectQuery) from routes in routesModel.Routes
join locales in localesModel.Locales
on routes.LocaleID equals locales.LocaleID
where locales.IsActive == true
select new {
LocaleID = routes.LocaleID,
RouteName = routes.RouteName
};
AdminTopListView.DataSource = routesQuery;
AdminTopListView.DataBind(); // this line cause the error
If there is no JOIN for tables all is OK. In all other cases i get the error says that there are 2 contexts for only one LINQ statement.
The questions are :
- what types except ObjectQuery can be accepted by ListView datasource?
- how to convert Anonymous Type returned by LINQ to ObjectQuery?
Thanks in advance.