Exemple #1
0
        public virtual SqlServerSettings BeforeBulkInsert(IDbConnection connection, IDbTransaction transaction, int timeout)
        {
            var database = connection.Database;
            var settings = new SqlServerSettings
            {
                PageVerify    = Util.AdHoc(connection, transaction, timeout, string.Format("SELECT page_verify_option_desc FROM sys.databases WHERE [NAME] = '{0}'", database)).ToString(),
                RecoveryModel = Util.AdHoc(connection, transaction, timeout, string.Format("SELECT recovery_model_desc FROM sys.databases WHERE [NAME] = '{0}'", database)).ToString()
            };

            Util.AdHoc(connection, transaction, timeout, "USE master;");
            Util.AdHoc(connection, transaction, timeout, string.Format("ALTER DATABASE [{0}] SET PAGE_VERIFY NONE;", database));
            Util.AdHoc(connection, transaction, timeout, string.Format("ALTER DATABASE [{0}] SET RECOVERY BULK_LOGGED", database));
            Util.AdHoc(connection, transaction, timeout, string.Format("USE [{0}]", database));

            return(settings);
        }
Exemple #2
0
        public virtual void AfterBulkInsert(IDbConnection connection, IDbTransaction transaction, int timeout, SqlServerSettings settings)
        {
            var database = connection.Database;

            Util.AdHoc(connection, transaction, timeout, "USE master");
            Util.AdHoc(connection, transaction, timeout, string.Format("ALTER DATABASE [{0}] SET PAGE_VERIFY {1};", database, settings.PageVerify));
            Util.AdHoc(connection, transaction, timeout, string.Format("ALTER DATABASE [{0}] SET RECOVERY {1}", database, settings.RecoveryModel));
            Util.AdHoc(connection, transaction, timeout, string.Format("USE [{0}]", database));
        }