Dbsession (Data session Class) is the core of data manipulation, and all database operations are done through it, so you have to instantiate the Dbsession object before writing the database access layer.
Now let's get to know this Dbsession object.
First, the dbsession of the instantiation configuration
Dbsession Two has a way of instantiating it.
1, through the configuration file creation
//指定connectionStrings节的名称来实例化DbSession
public DbSession(string connectName);
This approach is typically used for users who have already configured the connectionstrings section, as follows:
<connectionStrings>
<add name="DataExample" connectionString="Server=(local);Database=Northwind;Uid=sa;Pwd=sa;"
providerName="MySoft.Data.SqlServer9.SqlServer9Provider" />
</connectionStrings>
The above configuration section, if it is a Web project, is specified in web.config, if it is a WinForm project, the specified in app.config
The following providername specifies the drive used by the database link.
The above configuration is only for drivers that are already supported by. NET, such as Access,sqlserver,oracle
Default assembly is MySoft.Data.dll
If Mysql,firebird,sqlite requires additional assembly support, it needs to be configured as follows:
<connectionStrings>
<add name="DataExample" connectionString="Server=(local);Database=Northwind;Uid=sa;Pwd=sa;"
providerName="MySoft.Data.MySql.MySqlProvider, MySoft.Data.MySql" />
</connectionStrings>
ProviderName is written in front of ClassName, followed by AssemblyName.
and need to add related drivers, such as: MYSQL needs to add MySql.Data.dll and MySoft.Data.MySql.dll