Examples in a series of articles are dbsession.default as the entry point for manipulating data.
Default is the configuration that reads the last node of the connectionstrings node in the config file.
It is also recommended to create a dbsession in the actual project.
Can be written as follows:
public class Db
{
public readonly static DbSession Northwind = new DbSession ("NorthwindConnectionString");
static Db()
{
Northwind.RegisterSqlLogger(delegate(string sql)
{
File.AppendAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sqllog.txt"), sql);
});
}
}
This is the db.northwind as the entrance. There will be multiple connections in the project, as well as reference to similar wording. Inside the static constructor is a registration event to record the execution of SQL scripts to facilitate debugging and viewing. However, the log file will be more and more large, so write log SQL method needs to be modified, if you do not need to log the code comments can be. Of course, use log4net to write, there is no need to consider so much.
Northwind.RegisterSqlLogger(delegate(string sql)
{
Hxj.Common.Log4net.debug(sql);
});
End of this section.