views:

174

answers:

2

Hi,

My entity framework provider (CoreLabs/Mysql/devart) is creating ridiculously slow queries.

is it possible for me to set the actual sql query that will be executed?

Thanks

A: 

Yes, one way is with the ObjectQuery.ToTraceString API.

Andrew Peters
As far as I understood, the author asks how to substitute the SQL query to execute for a particular object query, but not how to read the underlying SQL.
Alex Yakunin
Sorry, misread that as "see". Yes, if EF v1 you can use stored procs to execute arbitrary SQL. See: http://msdn.microsoft.com/en-us/library/bb399203.aspx
Andrew Peters
+1  A: 

its funny, i was just watching LINQPad - New Features for Entity Framework. half way through the webcast, he showed the script generated by the EF and the same query generated by Linq-To-Sql; the linq-to-sql generated script was way more efficient. Now i don't know if using linq-to-sql is an option for you but i thought you should know,

in regards to your question, as i understand the whole point of EF and Linq-to-sql to avoid programmers writing TSQL in strings, doesn't force feeding your own SQL command kind of defeat the whole purpose of EF and Linq-to-sql?

Keivan