public DisabledForeignKeyCheckContext(SqlTransactionalCommandsContext context)
        {
            this.context = context;

            var command = ((DefaultSqlTransactionalCommandsContext)context).DbConnection.CreateCommand();

            // LogicalNot Azure compatible - command.CommandText = "EXEC sp_msforeachtable \"ALTER TABLE ? NOCHECK CONSTRAINT all\"";

            command.CommandText =
            @"DECLARE @table_name SYSNAME;
            DECLARE @cmd NVARCHAR(MAX);
            DECLARE table_cursor CURSOR FOR SELECT name FROM sys.tables;

            OPEN table_cursor;
            FETCH NEXT FROM table_cursor INTO @table_name;

            WHILE @@FETCH_STATUS = 0 BEGIN
              SELECT @cmd = 'ALTER TABLE '+QUOTENAME(@table_name)+' NOCHECK CONSTRAINT ALL';
              EXEC (@cmd);
              FETCH NEXT FROM table_cursor INTO @table_name;
            END

            CLOSE table_cursor;
            DEALLOCATE table_cursor;";

            command.ExecuteNonQuery();
        }
		public DisabledForeignKeyCheckContext(SqlTransactionalCommandsContext context)
		{
			var command = ((DefaultSqlTransactionalCommandsContext)context).CreateCommand();

			command.CommandText = "SET CONSTRAINTS ALL DEFERRED;";
			command.ExecuteNonQuery();
		}
		public DisabledForeignKeyCheckContext(SqlTransactionalCommandsContext context)
		{
			this.context = context;

			var command = ((DefaultSqlTransactionalCommandsContext)context).DbConnection.CreateCommand();

			command.CommandText = "SET FOREIGN_KEY_CHECKS = 0;";

			command.ExecuteNonQuery();
		}
		public DisabledForeignKeyCheckContext(SqlTransactionalCommandsContext context)
		{
			this.context = context;

			using (var command = ((DefaultSqlTransactionalCommandsContext)context).CreateCommand())
			{
				command.CommandText = "PRAGMA foriegn_keys = OFF;";

				command.ExecuteNonQuery();
			}
		}
		public override IDisabledForeignKeyCheckContext AcquireDisabledForeignKeyCheckContext(SqlTransactionalCommandsContext sqlDatabaseCommandsContext)
		{
			return new DisabledForeignKeyCheckContext(sqlDatabaseCommandsContext);	
		}
Exemplo n.º 6
0
 public abstract IDisabledForeignKeyCheckContext AcquireDisabledForeignKeyCheckContext(SqlTransactionalCommandsContext sqlDatabaseCommandsContext);
Exemplo n.º 7
0
		public MarsDbCommand(SqlTransactionalCommandsContext context, IDbCommand inner)
			: base(inner)
		{
			this.context = context;
		}
Exemplo n.º 8
0
 public MarsDbCommand(SqlTransactionalCommandsContext context, IDbCommand inner)
     : base(inner)
 {
     this.context = context;
 }
Exemplo n.º 9
0
		public abstract IDisabledForeignKeyCheckContext AcquireDisabledForeignKeyCheckContext(SqlTransactionalCommandsContext sqlDatabaseCommandsContext);
 public DisabledForeignKeyCheckContext(SqlTransactionalCommandsContext context)
 {
 }