Database Component hxj. Data (19th) (recommended dbsession Statement)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.