This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
|
|
|
Hi Dritan, Yes, absolutely - you can assign a logger on the LightSpeedContext. LightSpeed ships with a couple by default - a ConsoleLogger and a TraceLogger. This is handy for outputting the queries when running console apps or pumping them into the output window in Visual Studio while debugging. We try our best to "pretty print" the SQL so there is a performance impact of logging so you probably don't want to be logging the SQL in production. Hope that helps, John-Daniel Trask |
|
|
Cool. I just need this for development. Is there any sample on how to get this working? |
|
|
See Help Topics > LightSpeed > Logging in the help file. |
|
|
Oh, and if you are not using LightSpeedContext.Default, then you will need to change the line in the docs to: _myContext.Logger = ... Or, if you haven't kept a reference to the LightSpeedContext object, you can get at it through the unit of work: currentUnitOfWork.Context.Logger = ... |
|
|
Even though I am using the logger it is not printing any SQL statements. Mindscape.LightSpeed.Linq.LinqQuery`1[Twist.Twist.State] I don't know if this is because I am using LINQ or because I am using the logger incorrectly. My code looks like: Dim ctx As LightSpeedContext = New LightSpeedContext(Of TwistModelUnitOfWork)("TwistCtx")
|
|
|
You don't need to call LogSql yourself -- we call it for you. When you perform the query (which in the LINQ scenario will be when you start to enumerate the results, i.e. on the For Each line), the SQL will be logged automatically, in your case to the Trace output (the Visual Studio debug window). Are you not seeing that? If not, could you try using the ConsoleLogger instead and see if that solves the problem? It shouldn't be because of your using LINQ: logging works fine with LINQ, with the previously mentioned caveat that the SQL is not logged until it is executed, which is on the For Each line, not the Dim results line. |
|
|
The attempt to call LogSql was a desperate one indeed. I had to set pluralizeTableNames="false", because it was throwing a PLQ/SQL exception when it was set to "true" and the sql log printout was appearing only if you let the process run to the end. Weird Visual Studio stuff I guess. Thanks for the help. |
|