public async Task <RelationalDataReader> ExecuteReaderAsync(
            RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken = default)
        {
            var connection  = parameterObject.Connection;
            var errorNumber = PreExecution(connection);

            var result = await _realRelationalCommand.ExecuteReaderAsync(parameterObject, cancellationToken);

            if (errorNumber is not null)
            {
                connection.DbConnection.Close();
                result.Dispose(); // Normally, in non-test case, reader is disposed by using in caller code
                throw new PostgresException("", "", "", errorNumber);
            }

            return(result);
        }
            public Task <int> ExecuteNonQueryAsync(
                RelationalCommandParameterObject parameterObject,
                CancellationToken cancellationToken = new CancellationToken())
            {
                var connection  = parameterObject.Connection;
                var errorNumber = PreExecution(connection);

                var result = _realRelationalCommand.ExecuteNonQueryAsync(parameterObject, cancellationToken);

                if (errorNumber.HasValue)
                {
                    connection.DbConnection.Close();
                    throw OleDbExceptionFactory.CreateOleDbException(errorNumber.Value);
                }

                return(result);
            }
        public async Task <object> ExecuteScalarAsync(
            RelationalCommandParameterObject parameterObject,
            CancellationToken cancellationToken = default)
        {
            var connection  = parameterObject.Connection;
            var errorNumber = PreExecution(connection);

            var result = await _realRelationalCommand.ExecuteScalarAsync(parameterObject, cancellationToken);

            if (errorNumber.HasValue)
            {
                connection.DbConnection.Close();
                throw SqlExceptionFactory.CreateSqlException(errorNumber.Value);
            }

            return(result);
        }
Ejemplo n.º 4
0
        public static RelationalDataReader ExecuteSqlQuery(this DatabaseFacade databaseFacade, string sql, params object[] parameters)
        {
            var concurrencyDetector = databaseFacade.GetService <IConcurrencyDetector>();

            using (concurrencyDetector.EnterCriticalSection())
            {
                var rawSqlCommand = databaseFacade
                                    .GetService <IRawSqlCommandBuilder>()
                                    .Build(sql, parameters);

                var paramObject = new RelationalCommandParameterObject(databaseFacade.GetService <IRelationalConnection>(), rawSqlCommand.ParameterValues, null, null);

                return(rawSqlCommand
                       .RelationalCommand
                       .ExecuteReader(paramObject));
            }
        }
Ejemplo n.º 5
0
            public async Task <object> ExecuteScalarAsync(
                RelationalCommandParameterObject parameterObject,
                CancellationToken cancellationToken = new CancellationToken())
            {
                var connection  = parameterObject.Connection;
                var errorNumber = PreExecution(connection);

                var result = await _realRelationalCommand.ExecuteScalarAsync(parameterObject, cancellationToken);

                if (errorNumber != null)
                {
                    connection.DbConnection.Close();
                    throw new PostgresException("", "", "", errorNumber);
                }

                return(result);
            }
Ejemplo n.º 6
0
            public async Task <RelationalDataReader> ExecuteReaderAsync(
                RelationalCommandParameterObject parameterObject,
                CancellationToken cancellationToken = new CancellationToken())
            {
                var connection  = parameterObject.Connection;
                var errorNumber = PreExecution(connection);

                var result = await _realRelationalCommand.ExecuteReaderAsync(parameterObject, cancellationToken);

                if (errorNumber.HasValue)
                {
                    connection.DbConnection.Close();
                    result.Dispose(); // Normally, in non-test case, reader is disposed by using in caller code
                    throw SqlExceptionFactory.CreateSqlException(errorNumber.Value);
                }

                return(result);
            }
        private static async Task <RelationalDataReader> ExecuteSqlQueryAsync(
            this DbContext dbContext,
            string sql,
            IEnumerable <object> parameters,
            CancellationToken cancellationToken = default)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

            if (string.IsNullOrWhiteSpace(sql))
            {
                throw new ArgumentNullException(nameof(sql));
            }

            IConcurrencyDetector concurrencyDetector = dbContext.GetService <IConcurrencyDetector>();

            using (concurrencyDetector.EnterCriticalSection())
            {
                RawSqlCommand rawSqlCommand = dbContext
                                              .GetService <IRawSqlCommandBuilder>()
                                              .Build(sql, parameters);

                RelationalCommandParameterObject paramObject = new RelationalCommandParameterObject(
                    dbContext.GetService <IRelationalConnection>(),
                    rawSqlCommand.ParameterValues,
                    null,
                    null,
                    null);

                RelationalDataReader relationalDataReader = await rawSqlCommand
                                                            .RelationalCommand
                                                            .ExecuteReaderAsync(paramObject, cancellationToken);

                return(relationalDataReader);
            }
        }
 public Task <int> ExecuteNonQueryAsync(
     RelationalCommandParameterObject parameterObject,
     CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }
 public int ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
 public object ExecuteScalar(RelationalCommandParameterObject parameterObject)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 11
0
 public Task <int> ExecuteNonQueryAsync(
     RelationalCommandParameterObject parameterObject,
     CancellationToken cancellationToken = default)
 => Task.FromResult(0);
Ejemplo n.º 12
0
 public int ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
 {
     return(0);
 }
 public RelationalDataReader ExecuteReader(RelationalCommandParameterObject parameterObject)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 14
0
 public Task <object> ExecuteScalarAsync(
     RelationalCommandParameterObject parameterObject,
     CancellationToken cancellationToken = default)
 => throw new NotImplementedException();
Ejemplo n.º 15
0
 public int ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
 => 0;
 public object ExecuteScalar(RelationalCommandParameterObject parameterObject)
 => Interlocked.Add(ref _commandBuilder._current, _commandBuilder._blockSize);
 public Task <object> ExecuteScalarAsync(
     RelationalCommandParameterObject parameterObject,
     CancellationToken cancellationToken = default)
 => Task.FromResult <object>(Interlocked.Add(ref _commandBuilder._current, _commandBuilder._blockSize));
Ejemplo n.º 18
0
 public DbCommand CreateDbCommand(RelationalCommandParameterObject parameterObject, Guid commandId, DbCommandMethod commandMethod)
 => throw new NotImplementedException();
 public Task <RelationalDataReader> ExecuteReaderAsync(
     RelationalCommandParameterObject parameterObject,
     CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 20
0
 public Task <int> ExecuteNonQueryAsync(
     RelationalCommandParameterObject parameterObject,
     CancellationToken cancellationToken = new())