Performance monitoring and logging

5 posts, 1 answers
  1. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 23 Mar 2009 Link to this post

    My goal is to "just dump" the sql's generated by OpenAccess during a query like this:

    var result = os.Extent<UserRole>().Where(condition1 + condition2).Select("new (User.UserID, User.Email, User.FuldeNavn, Medlemsnummer, Role.RoleName, SidsteLogon)");  
    RadGrid1.DataSource = result;  
     

    1. Been reading: "Performance monitoring and logging" in the on-line manual.
    2. Been searching/reading in the CHM file that comes with OpenAccess.
    3. Been searching the forums
    4. Been watching the OpenAccess demos, and their code behind.
    5. Setup inside "Backend Configuration Settings" on my project (point to a text file).

    No dumps, nothing happens, even after all that searching and reading.

    Can you provide a "running" sample?
  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 24 Mar 2009 Link to this post

    Hi Bo,

    the result.BackendQuery string property contains the SQL that was generated.

    You can also turn on logging (OpenAccess->Configuration->Backend-> Logging) and watch the executed queries. The output can be put onto System.Console, System.Diagnostics.Trace or a file.

    All the best,
    Thomas
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 24 Mar 2009 Link to this post

    Hi,

    1. The property: result.BackendQuery does not exists!
    2. As stated in 5. - I have set all regarding the "dump" - but the text file remain empty.

    Here are my code:

    IObjectScope os = (IObjectScope)Context.Items["ObjectScopeProvider"];  
    var condition1 = string.Format("PortalID == {0} and ({1} == 0 or sup1 == {1})", Utilities.CurrentPortalid(), getSup1());  
    var condition2 = string.Empty;  
    var result = os.Extent<UserRole>().Where(condition1 + condition2).Select("new (User.UserID, User.Email, User.FuldeNavn, Medlemsnummer, Role.RoleName, SidsteLogon)");  
    RadGrid1.DataSource = result;  
     

    The code execute fine - I just want to see the SQL generated.

  5. Answer
    Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 26 Mar 2009 Link to this post

    Hi Bo Hessner,

    you are right, the type IQueryable (which is created by the dynamic LINQ) does not have a BackendQuery property. However, the instance that is used has! Which means you could use a little reflection to get
    to the value:

    Console.WriteLine( result.GetType().GetProperty("BackendQuery").GetValue(result,null) );

    In the VS debugger, you can also see the generated backend query during hovering over the result variable when 'Enable property evaluation' is turned on (Tools->Options->Debugging). It is using  the DebuggerDisplayAttribute.

    Wrt. to the other issue that nothing is written to the trace file I would like to ask you for the backend configuration element that you use as this controls the trace generation.

    Kind regards,
    Thomas
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 26 Mar 2009 Link to this post

    Perfect, thank you.
Back to Top
DevCraft banner