Ejemplo n.º 1
0
        public SqlServerReader(
            string connectionString,
            FullTableName tableName,
            TargetFileNameController targetController
            )
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            if (tableName == null)
            {
                throw new ArgumentNullException(nameof(tableName));
            }

            if (targetController == null)
            {
                throw new ArgumentNullException(nameof(targetController));
            }

            _connectionString = connectionString;
            _tableName        = tableName;
            _targetController = targetController;
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public SqlServerCollectionSaver(
            SqlConnection connection,
            SqlTransaction transaction,
            FullTableName tableName,
            TargetFileNameController targetController
            )
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            if (transaction == null)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            if (tableName == null)
            {
                throw new ArgumentNullException(nameof(tableName));
            }

            if (targetController == null)
            {
                throw new ArgumentNullException(nameof(targetController));
            }

            _connection       = connection;
            _transaction      = transaction;
            _targetController = targetController;

            _command = new SqlCommand($@"
insert into {tableName.CombinedName}
    ( insert_date, file_name, offset, length )
values
    ( GETDATE(), @fileName, @offset, @length )
",
                                      connection,
                                      transaction
                                      );
            _command.Parameters.Add("fileName", SqlDbType.VarChar, 261);
            _command.Parameters.Add("offset", SqlDbType.BigInt);
            _command.Parameters.Add("length", SqlDbType.BigInt);
            _command.Prepare();
        }