Exemple #1
0
 private static long GetLength(ReliableSqlConnection connection, string schemaName, string tableName, string dataColumn, string keyColumn, SqlDbType keyType, object keyValue)
 {
     using (IDbCommand getLengthCommand = SqlCommandFactory.CreateSqlStreamGetSizeCommand(connection, schemaName, tableName, dataColumn, keyColumn, keyType, keyValue))
     {
         return(GetLength(connection, getLengthCommand));
     }
 }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of a <see cref="SqlStream"/> object using the specified custom commands for manipulating with the source field holding the underlying data.
        /// </summary>
        /// <param name="connection">The database connection providing access to the underlying data.</param>
        /// <param name="readCommand">The instance of a SQL command responsible for retrieving the data from the source field.</param>
        /// <param name="writeCommand">The instance of a SQL command responsible for updating the data held in the source field.</param>
        /// <param name="getLengthCommand">The instance of a SQL command responsible for returning the size of the data held in the source field.</param>
        public SqlStream(ReliableSqlConnection connection, SqlCommand readCommand, SqlCommand writeCommand, SqlCommand getLengthCommand)
        {
            Guard.ArgumentNotNull(connection, "connection");
            Guard.ArgumentNotNull(readCommand, "readCommand");
            Guard.ArgumentNotNull(writeCommand, "writeCommand");
            Guard.ArgumentNotNull(getLengthCommand, "getLengthCommand");

            this.readCommand        = readCommand;
            this.writeCommand       = writeCommand;
            this.commandRetryPolicy = connection.CommandRetryPolicy;
            this.dataLength         = GetLength(connection, getLengthCommand);
            this.disposeCommands    = false;
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of a <see cref="SqlStream"/> object using the specified details describing the source field holding the underlying data.
        /// </summary>
        /// <param name="connection">The database connection providing access to the underlying data.</param>
        /// <param name="schemaName">The name of the database schema holding the source table.</param>
        /// <param name="tableName">The name of the database table holding the source field containing the data.</param>
        /// <param name="dataColumn">The name of the database column holding the data.</param>
        /// <param name="keyColumn">The name of the database field which represents a lookup key for the source row containing the data.</param>
        /// <param name="keyType">The type of the lookup key.</param>
        /// <param name="keyValue">The value of the lookup key.</param>
        public SqlStream(ReliableSqlConnection connection, string schemaName, string tableName, string dataColumn, string keyColumn, SqlDbType keyType, object keyValue)
        {
            Guard.ArgumentNotNull(connection, "connection");
            Guard.ArgumentNotNullOrEmptyString(schemaName, "schemaName");
            Guard.ArgumentNotNullOrEmptyString(tableName, "tableName");
            Guard.ArgumentNotNullOrEmptyString(dataColumn, "dataColumn");
            Guard.ArgumentNotNullOrEmptyString(keyColumn, "keyColumn");
            Guard.ArgumentNotNull(keyValue, "keyValue");

            this.dataLength         = GetLength(connection, schemaName, tableName, dataColumn, keyColumn, keyType, keyValue);
            this.readCommand        = SqlCommandFactory.CreateSqlStreamReadCommand(connection, schemaName, tableName, dataColumn, keyColumn, keyType, keyValue) as SqlCommand;
            this.writeCommand       = SqlCommandFactory.CreateSqlStreamWriteCommand(connection, schemaName, tableName, dataColumn, keyColumn, keyType, keyValue) as SqlCommand;
            this.commandRetryPolicy = connection.CommandRetryPolicy;
            this.disposeCommands    = true;
        }
Exemple #4
0
        private static long GetLength(ReliableSqlConnection connection, IDbCommand getLengthCommand)
        {
            long?length = connection.ExecuteCommand <long?>(getLengthCommand);

            return(length.HasValue ? length.Value : 0);
        }