Hi all.
Plz help. I have this query and its result implements IEnumerable.
RoutesEntities routesModel = new RoutesEntities();
LocalesEntities localesModel = new LocalesEntities();
var routesQuery = from rs in routesModel.Routes.ToList()
join ls in localesModel.Locales.ToList()
on rs.LocaleID equals ls.LocaleID
select new
{
LocaleID = rs.LocaleID,
RouteName = rs.RouteName
};
Question : How to get generated SQL from this query, or how to convert its type to ObjectQuery to use routesQuery.ToTraceString(). Is it possible?
Reason : I want to log all SQL queries to DB, though I don't want to create new object for joined contexts (tables)
Important : I can't use ObjectQuery initially because after all I use
ListView.DataSource = routesQuery;
ListView.DataBind()
And it can cause an error of using to different contexts (DB tables) for one datasource.
So what should I do get generated SQL query?
Thanks in advance.