This is a migrated thread and some comments may be shown as answers.

View Dynamically Generated OpenAccess SQL

2 Answers 176 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brendan Enrick
Top achievements
Rank 1
Brendan Enrick asked on 26 Oct 2009, 02:02 PM
I'd like to be able to see the query that is generated and used by OpenAccess to request the data. Is this possible? Perhaps there is someway to turn on debugging and see the queries.

If this isn't possible I'd like to suggest adding it to future versions of OpenAccess. This would really allow people to see what their queries are doing, and can help greatly in debugging issues.

Thanks,
Brendan

2 Answers, 1 is accepted

Sort by
0
Brendan Enrick
Top achievements
Rank 1
answered on 26 Oct 2009, 02:23 PM
Found it! I'll post about it here so others can have the answer as well.

There is a property called BackendQuery. It is on the unexecuted query object, so you can view the query like this.

IObjectScopeQuery<MyDomainObject> mdoList = from mdo in _objectScope.Extent<MyDomainObject>() 
    where mdo.CreatedDate >= startDate && mdo.CreatedDate < endDate 
    select mdo; 
 
var sqlQuery = mdoList.BackendQuery; 
 
// log, write, or print the generated sql here 


I hope that helps someone,
Brendan
0
PetarP
Telerik team
answered on 28 Oct 2009, 07:20 AM
Hello Brendan Enrick,

Yes, this is one possible way. The other option would be to use our integrated mechanism for tracing and logging the communication between the application and the database server. Additional information on this can be found here.
You can always use Performance measuring tools such as SQL Profiler to intercept the SQL statements that hit the server.

Sincerely yours,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Getting Started
Asked by
Brendan Enrick
Top achievements
Rank 1
Answers by
Brendan Enrick
Top achievements
Rank 1
PetarP
Telerik team
Share this question
or