NHibernate ADO.NET 属性
Property name | Purpose |
---|---|
connection.provider_class | The type of a custom IConnectionProvider.
eg. full.classname.of.ConnectionProvider if the Provider is built into NHibernate, or full.classname.of.ConnectionProvider, assembly if using an implementation of IConnectionProvider not included in NHibernate. |
connection.driver_class | The type of a custom IDriver, if using DriverConnectionProvider.
full.classname.of.Driver if the Driver is built into NHibernate, or full.classname.of.Driver, assembly if using an implementation of IDriver not included in NHibernate. This is usually not needed, most of the time the dialect will take care of setting the IDriver using a sensible default. See the API documentation of the specific dialect for the defaults. |
connection.connection_string | Connection string to use to obtain the connection. |
connection.connection_string_name | The name of the connection string (defined in <connectionStrings> configuration file element) to use to obtain the connection. |
connection.isolation | Set the ADO.NET transaction isolation level. Check System.Data.IsolationLevel for meaningful values and the
database's documentation to ensure that level is supported.
eg. Chaos, ReadCommitted, ReadUncommitted, RepeatableRead, Serializable, Unspecified |
connection.release_mode | Specify when NHibernate should release ADO.NET connections. See Section 10.7,
“Connection Release Modes”.
eg. auto (default) | on_close | after_transaction Note that this setting only affects ISessions returned from ISessionFactory.OpenSession. For ISessions obtained through ISessionFactory.GetCurrentSession, the ICurrentSessionContext implementation configured for use controls the connection release mode for those ISessions. See Section 2.3, “Contextual Sessions”. |
command_timeout | Specify the default timeout of IDbCommands generated by NHibernate. |
adonet.batch_size | Specify the batch size to use when batching update statements. Setting this to 0 (the default) disables the functionality. See Section 17.6, “Batch updates”. |
NHibernate ADO.NET 属性
属性名 | 用途 |
---|---|
connection.provider_class | 实现IConnectionProvider接口的类型。
例如: (如果是NHibernate内部的IConnectionProvider实现类)full.classname.of.ConnectionProvider,(如果是自定义的NHibernate外部的IConnectionProvider实现类 )full.classname.of.ConnectionProvider, assembly。 |
connection.driver_class | 如果使用DriverConnectionProvider,实现IDriver接口的类型。
(如果是NHibernate内部的实现的IDriver类型)full.classname.of.Driver (如果是自定义的NHibernate外部的IDriver实现类 )full.classname.of.Driver, assembly。 这个配置通常是不需要配置的,如果设置好了hibernate.dialect一般会自动选好对应的IDriver。 详细的dialect与IDriver的默认对应关系可以查看API文档。 |
connection.connection_string | 数据库连接字符串 |
connection.connection_string_name | 数据库连接字符串名称(定义在.Net配置文件<connectionStrings>配置节里面的连接字符串名。 |
connection.isolation | ADO.NET事务隔离级别, 查看System.Data.IsolationLevel类来了解各个值的具体意义, 但请注意多数数据库都不支持所有的隔离级别.
例如: Chaos, ReadCommitted, ReadUncommitted, RepeatableRead, Serializable, Unspecified |
connection.release_mode | 指定ADO.NET何时释放数据库连接。查看10.7 连接释放模式.
例如: auto (默认) | on_close | after_transaction 注意,这些设置仅对通过ISessionFactory.OpenSession得到的ISession起作用。对于通过ISessionFactory.GetCurrentSession得到的ISession, 所配置的ICurrentSessionContext实现控制这些ISession的连接释放模式。 请参阅2.3. 上下文相关的(Contextual)Session获取更多信息。 |
command_timeout | 指定NHibernate生成的IDbCommands对象的超时时间。 . |
adonet.batch_size | 指定用ADO.Net的批量更新的数量,默认设置为0(不启用该功能)。请参阅 16.6. 批量更新. |
下面是一个如何在web.config里如何设置数据库连接属性的例子: