0

Can someone tell he how i can setup my fluent nhibernate connection to always connect as follows

  • SET NOCOUNT ON
  • SET ARITHABORT ON
  • SET NUMERIC_ROUNDABORT ON

this is what i have at the moment

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

            fluentConfiguration = fluentConfiguration.Cache(c => c
                    .UseQueryCache()
                    .UseMinimalPuts()
                    .ProviderClass<HashtableCacheProvider>());

thanks Niall

1 Answer 1

1

Well your can customize that in DriverConnectionProvider. Custome properties how set numer... etc is for session so you could do it using 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.

References Nhibernate 3.0 cookbook

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.