Fluent nhibernate 如何配置fluent nHibernate连接属性

Fluent nhibernate 如何配置fluent nHibernate连接属性,fluent-nhibernate,Fluent Nhibernate,有人能告诉他我如何设置我的fluent nhibernate连接,使其始终连接如下吗 不计较 启用ARITHABORT 将数字_ROUNDABORT设置为ON 这就是我现在所拥有的 var fluentConfiguration = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008.ConnectionString(ConnectionString).ShowSql(

有人能告诉他我如何设置我的fluent nhibernate连接,使其始终连接如下吗

  • 不计较
  • 启用ARITHABORT
  • 将数字_ROUNDABORT设置为ON
这就是我现在所拥有的

            var fluentConfiguration = Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2008.ConnectionString(ConnectionString).ShowSql());

            fluentConfiguration = fluentConfiguration.Cache(c => c
                    .UseQueryCache()
                    .UseMinimalPuts()
                    .ProviderClass<HashtableCacheProvider>());
var fluentConfiguration=Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(ConnectionString.ShowSql());
fluentConfiguration=fluentConfiguration.Cache(c=>c
.UseQueryCache()
.usemplots()文件
.ProviderClass());
谢谢
所有这些都可以在DriverConnectionProvider中自定义。自定义属性如何设置数字。。。etc用于会话,因此您可以使用driverconnectionproperties来完成

public class ContextConnectionDriver : DriverConnectionProvider
{
  public override IDbConnection GetConnection()
  {
    var conn = base.GetConnection();
    SetContext(conn);
    return conn;
  }
  private void SetContext(IDbConnection conn)
  {
    string const COMMAND_TEXT = "SET NOCOUNT ON;SET ARITHABORT ON;SET NUMERIC_ROUNDABORT ON;";
    var cmd = conn.CreateCommand();
       cmd.CommandType = CommandType.Text;
       cmd.CommandText = COMMAND_TEXT;           
       cmd.ExecuteNonQuery();
  }
}


Set the NHibernate property connection.provider to <namespace>. ContextConnectionDriver, <assembly>
,to set the namespace and assembly according to the name of your project.
公共类ContextConnectionDriver:DriverConnectionProvider
{
公共覆盖IDbConnection GetConnection()
{
var conn=base.GetConnection();
SetContext(康涅狄格州);
返回连接;
}
私有void SetContext(IDbConnection)
{
string const COMMAND_TEXT=“设置NOCOUNT ON;设置arithaport ON;设置NUMERIC_ROUNDABORT ON;”;
var cmd=conn.CreateCommand();
cmd.CommandType=CommandType.Text;
cmd.CommandText=命令文本;
cmd.ExecuteNonQuery();
}
}
将NHibernate属性connection.provider设置为。康涅狄格河,
,以根据项目名称设置命名空间和程序集。
参考Nhibernate 3.0食谱