View Dynamically Generated OpenAccess SQL

3 posts, 0 answers
  1. Brendan Enrick
    Brendan Enrick avatar
    28 posts
    Member since:
    Jul 2009

    Posted 26 Oct 2009 Link to this post

    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. Brendan Enrick
    Brendan Enrick avatar
    28 posts
    Member since:
    Jul 2009

    Posted 26 Oct 2009 Link to this post

    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
  3. DevCraft banner
  4. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 28 Oct 2009 Link to this post

    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.
Back to Top