This question is locked. New answers and comments are not allowed.
I found out, that your OpenAccess is a very advanced Linq-Provider. I'd like to use it to generate SQL-Selects.
Is is possible to just get the sql-command that would be used to query the database by executing the IQueryable<Entity> query?
I'd like to use this query to execute it directly on the server using an insert into .. select ... command-chain without the unecessary traffic back and forth to the client.
Any suggestions would be appreciated.
Is is possible to just get the sql-command that would be used to query the database by executing the IQueryable<Entity> query?
I'd like to use this query to execute it directly on the server using an insert into .. select ... command-chain without the unecessary traffic back and forth to the client.
Any suggestions would be appreciated.
6 Answers, 1 is accepted
0

Adrian
Top achievements
Rank 2
answered on 05 Sep 2012, 10:59 PM
Hello Florin (Salut Florian)
Check this link:
http://www.telerik.com/help/openaccess-orm/openaccess-tasks-howto-execute-sql-query.html
Check this link:
http://www.telerik.com/help/openaccess-orm/openaccess-tasks-howto-execute-sql-query.html
0

Florian
Top achievements
Rank 1
answered on 06 Sep 2012, 07:08 AM
Hi Neagoe!
Thanks for your answer which unfortunately doesn't answer my question ;-) (Or I didn't get it)
Regards,
Florian
Thanks for your answer which unfortunately doesn't answer my question ;-) (Or I didn't get it)
Regards,
Florian
0
Hello Florian,
You can just call ToString() on the Linq query to get the SQL statement which would be executed on the server. Any parameter values, however, would not be included in this string, so you may have to add them manually. Here is an example how to obtain the SQL:
Regards,
Alexander
the Telerik team
You can just call ToString() on the Linq query to get the SQL statement which would be executed on the server. Any parameter values, however, would not be included in this string, so you may have to add them manually. Here is an example how to obtain the SQL:
EntitiesModel context =
new
EntitiesModel();
var query = context.Categories.Where(c => c.CategoryID == 2);
string
sql = query.ToString();
Regards,
Alexander
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
0

Florian
Top achievements
Rank 1
answered on 06 Sep 2012, 03:09 PM
Alexander, thanks for your answer.
I'll see, it that fits my needs.
I thought there would be a way to get the parametrized dbCommand.
Regards,
Florian
I'll see, it that fits my needs.
I thought there would be a way to get the parametrized dbCommand.
Regards,
Florian
0
Hi Florian,
I am afraid that there is no way to obtain the dbCommand that OpenAccess uses internally. The ToString() trick is the only option at the moment.
Kind regards,
Alexander
the Telerik team
I am afraid that there is no way to obtain the dbCommand that OpenAccess uses internally. The ToString() trick is the only option at the moment.
Kind regards,
Alexander
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
0