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

Performance monitoring and logging

4 Answers 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hessner
Top achievements
Rank 2
Hessner asked on 23 Mar 2009, 10:52 PM

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?

4 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 24 Mar 2009, 08:21 AM
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.
0
Hessner
Top achievements
Rank 2
answered on 24 Mar 2009, 04:09 PM
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.

0
Accepted
Thomas
Telerik team
answered on 26 Mar 2009, 12:33 PM
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.
0
Hessner
Top achievements
Rank 2
answered on 26 Mar 2009, 10:15 PM
Perfect, thank you.
Tags
General Discussions
Asked by
Hessner
Top achievements
Rank 2
Answers by
Thomas
Telerik team
Hessner
Top achievements
Rank 2
Share this question
or