Exemplo n.º 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));
     }
 }
Exemplo n.º 2
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;
        }