Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Designer> Exposing DynamicQueryEngineBase.Switch.Level)
 

Pages: 1
Designer
Exposing DynamicQueryEngineBase.Switch.Level)
Page:1/1 

  Print all messages in this thread  
Poster Message
JimHugh
User



Location:
Davis, CA
Joined on:
16-Nov-2005 14:32:25
Posted:
191 posts
# Posted on: 12-Feb-2006 03:14:10.  
Using 1.2005.1 Adapter model with WinForms.

I would like to change tracing levels at runtime without having to modify the app.config or restart the app.

I can see that it is a static variable and assigned in the file DynamicQueryEngine.cs, but as far as I can tell, it is not visible to the end user code similar to the way that TraceHelper makes the LLBL traceswitches visible.

Based on my concept code below, I can change the three LLBL switches at runtime, but it does not appear that the SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.Switch.Level variable is exposed via the SQL Server driver.

Code:

Imports SD.LLBLGen.Pro.ORMSupportClasses.TraceHelper

        Trace.WriteLine(GeneralSwitch.DisplayName & " " & GeneralSwitch.Level.ToString)
        Trace.WriteLine(PersistenceExecutionSwitch.DisplayName & " " & PersistenceExecutionSwitch.Level.ToString)
        Trace.WriteLine(StateManagementSwitch.DisplayName & " " & StateManagementSwitch.Level.ToString)
        'Trace.WriteLine(SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.Switch.Level)

        GeneralSwitch.Level = TraceLevel.Verbose
        PersistenceExecutionSwitch.Level = TraceLevel.Verbose
        StateManagementSwitch.Level = TraceLevel.Verbose

        Trace.WriteLine(GeneralSwitch.DisplayName & " " & GeneralSwitch.Level.ToString)
        Trace.WriteLine(PersistenceExecutionSwitch.DisplayName & " " & PersistenceExecutionSwitch.Level.ToString)
        Trace.WriteLine(StateManagementSwitch.DisplayName & " " & StateManagementSwitch.Level.ToString)



Code:

' Sample Startup Switch Values to be sure I was referring to the correct entries.
<add name="SqlServerDQE" value="4" />
<add name="ORMGeneral" value="3" />
<add name="ORMStateManagement" value="2" />
<add name="ORMPersistenceExecution" value="1" />

'Trace output
ORMGeneral Info
ORMPersistenceExecution Error
ORMStateManagement Warning
ORMGeneral Verbose
ORMPersistenceExecution Verbose
ORMStateManagement Verbose

Jim Hughes  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38044 posts
# Posted on: 14-Feb-2006 11:41:27.  
Great idea Regular Smiley

You can set the switch for the DQE though Regular Smiley, it's a static property of DynamicQueryEngineBase, so you can do:
DynamicQueryEngineBase.Switch.Level = myLevel;

or refer to SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.Switch.Level...

Please let me know if this doesn't work for you.




Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
JimHugh
User



Location:
Davis, CA
Joined on:
16-Nov-2005 14:32:25
Posted:
191 posts
# Posted on: 14-Feb-2006 15:01:23.  
That is what I was hoping Regular Smiley However, trying to query the current level with

Code:

Trace.WriteLine(SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.Switch.Level)


Generates "A first chance exception of type 'System.NullReferenceException' occurred in WindowsApplication1.exe
Object reference not set to an instance of an object.

I finally figured out a way to accomplish my goal. Regular Smiley Use an adapter at least once BEFORE trying to set the trace switch!

Silly me, I assumed it would be set like the other three were!

Thanks for pointing me in the right direction.

This code works for me:
Code:

        Using adapter As IDataAccessAdapter = Database.GetAdapter
            Dim app As New HTI.FFBL.EntityClasses.ApplicationEntity(1)
            adapter.FetchEntity(app)
        End Using
        Trace.WriteLine(TraceHelper.GeneralSwitch.DisplayName & " " & TraceHelper.GeneralSwitch.Level.ToString)
        Trace.WriteLine(TraceHelper.PersistenceExecutionSwitch.DisplayName & " " & TraceHelper.PersistenceExecutionSwitch.Level.ToString)
        Trace.WriteLine(TraceHelper.StateManagementSwitch.DisplayName & " " & TraceHelper.StateManagementSwitch.Level.ToString)
        Trace.WriteLine(SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.Switch.DisplayName & " " & SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.Switch.Level)

        TraceHelper.GeneralSwitch.Level = TraceLevel.Verbose
        TraceHelper.PersistenceExecutionSwitch.Level = TraceLevel.Verbose
        TraceHelper.StateManagementSwitch.Level = TraceLevel.Verbose
        SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.Switch.Level = TraceLevel.Verbose
Jim Hughes  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38044 posts
# Posted on: 14-Feb-2006 15:28:52.  
I think it's a matter of triggering the static constructor. So if you'd do:
bool dummy = SD.LLBLGen.Pro.DQE.SqlServer.DynamicQueryEngine.ArithAbortOn;
it should trigger the load of the type and the static constructor. The code you use doesn't trigger the static constructor (which creates the trace switch Wink) because it's a base class used in all DQEs.

Though fetching something of course also works Wink Regular Smiley Thanks for sharing! It can be helpful to some people to have this kind of code in their app so they don't have to re-start the application (and possibly wait a long time before a certain situation kicks in). I'll add to my todo list to investigate how this could be done by attaching another application (or debugger).


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
DvK
User



Location:
Delft (centre), Netherlands
Joined on:
22-Mar-2006 10:43:57
Posted:
292 posts
# Posted on: 24-Aug-2007 16:27:34.  
Is there anyway to show the trace to a different window other then the debug window ?
For example, tracing all SQL calls the LLBLGen datalayer produces in a production environment so you can get detailed info on SQL traffic on client locations with release versions of your application.

Kind regards,
Danny
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38044 posts
# Posted on: 25-Aug-2007 11:14:59.  
Sure, setup a trace listener. There are a couple in .NET, so you could for example specify in the config file the stdout trace listener and in a textbox show that stdout Regular Smiley

Please see the MSDN docs about trace listeners for details.


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.