In SeriesArticleThe examples in are dbsession. Default as the entry to the operation data.
Default is the configuration of the last node of the connectionstrings node in the config file.
We recommend that you create a dbsession in the actual project.
It can be written as follows:
Public classDB{Public readonly staticDbsessionNorthwind =NewDbsession("Northwindconnectionstring");StaticDB () {northwind. registersqllogger (Delegate(StringSQL ){File. Appendalltext (Path. Combine (Appdomain. Currentdomain. basedirectory,"Sqllog.txt"), SQL );});}}
In this way, DB. northwind is used as the portal.
There will be multiple connections in the project, and you can refer to similar writing.
The static constructor registers an event to record the script for executing the SQL statement to facilitate debugging and viewing.
However, the log file will become larger and larger, so you need to modify the SQL Method for writing logs. If you do not need to record logsCodeComment it out.
Of course, if you use log4net for writing, you do not need to consider that much.
Northwind. registersqllogger (Delegate(StringSQL) {hxj. Common.Log4net. Debug (SQL );});
This section is complete.