Example #1
0
        public SqlReplayerCommand(
            SqlReplayerConnection connection,
            Func <QueryCriteria, IDataReader> dataRetriever,
            Func <QueryCriteria, Tuple <object> > scalarDataRetriever,
            Func <QueryCriteria, int?> nonQueryRowCountDataRetriever)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }
            if (dataRetriever == null)
            {
                throw new ArgumentNullException(nameof(dataRetriever));
            }
            if (scalarDataRetriever == null)
            {
                throw new ArgumentNullException(nameof(scalarDataRetriever));
            }
            if (nonQueryRowCountDataRetriever == null)
            {
                throw new ArgumentNullException(nameof(nonQueryRowCountDataRetriever));
            }

            _connection                    = connection;
            _dataRetriever                 = dataRetriever;
            _scalarDataRetriever           = scalarDataRetriever;
            _nonQueryRowCountDataRetriever = nonQueryRowCountDataRetriever;
            Parameters = new SqlReplayerParameterCollection();

            // Apply some sensible defaults - important for properties whose default state is invalid (eg. there is no zero value for the CommandType
            // enum) but more important that the property defaults here match those on SqlParameter for when the replayer aspect of the services comes
            // to look in its cache (it will check that the connection, command and parameters are consistent between the current request and any cache
            // entry, the type of command - eg. Text or StoredProcedure - is important)
            CommandType = CommandType.Text;
        }
        public SqlReplayerTransaction(SqlReplayerConnection connection, IsolationLevel isolationLevel)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            Connection     = connection;
            IsolationLevel = IsolationLevel;
        }