Beispiel #1
0
        public static object ExecuteScalar(this IDbCommandExecutor executor, CreateCommandRequest request)
        {
            object scalar = null;

            executor.Execute(request, command => scalar = command.ExecuteScalar());
            return(scalar);
        }
Beispiel #2
0
        public static DbCommand CreateCommand(this DbConnection connection, CreateCommandRequest request)
        {
            var command = connection.CreateCommand();

            command.Initialize(request);
            return(command);
        }
Beispiel #3
0
        public static void Execute(this IDbCommandExecutor executor, CreateCommandRequest request, Action <IDbCommand> execute)
        {
            Assert.IsNotNull(executor);
            var requests = new ExecuteCommandRequest(request, execute).ItemToArray();

            executor.Execute(requests);
        }
Beispiel #4
0
        public static int ExecuteNonQuery(this IDbCommandExecutor executor, CreateCommandRequest request)
        {
            var affectedRows = 0;

            executor.Execute(request, command => affectedRows = command.ExecuteNonQuery());
            return(affectedRows);
        }
Beispiel #5
0
        public ExecuteCommandAsyncRequest(CreateCommandRequest createCommandRequest, Func <DbCommand, Task> execute)
        {
            Assert.IsNotNull(createCommandRequest);
            Assert.IsNotNull(execute);

            CreateCommandRequest = createCommandRequest;
            Execute = execute;
        }
Beispiel #6
0
        public ExecuteReaderRequest(CreateCommandRequest createCommandRequest, CommandBehavior commandBehavior, CancellationToken cancellationToken)
        {
            Assert.IsNotNull(createCommandRequest);

            CreateCommandRequest = createCommandRequest;
            CommandBehavior      = commandBehavior;
            CancellationToken    = cancellationToken;
        }
        public ExecuteCommandRequest(CreateCommandRequest createCommandRequest, Action <IDbCommand> execute)
        {
            Assert.IsNotNull(createCommandRequest);
            Assert.IsNotNull(execute);

            CreateCommandRequest = createCommandRequest;
            Execute = execute;
        }
Beispiel #8
0
        public static void Execute(this IDbCommandExecutor executor, CreateCommandRequest request, Action <IDbCommand> execute)
        {
            var requests = new[]
            {
                new ExecuteCommandRequest(request, execute)
            };

            executor.Execute(requests);
        }
Beispiel #9
0
        internal static void Initialize(this IDbCommand command, CreateCommandRequest request)
        {
            command.CommandType    = request.CommandType;
            command.CommandText    = request.CommandText;
            command.CommandTimeout = request.CommandTimeout;
            command.Transaction    = request.Transaction;

            if (request.Parameters != null)
            {
                command.Parameters.AddRange(request.Parameters);
            }
        }
 public ExecuteNonReaderRequest(CreateCommandRequest createCommandRequest, CancellationToken cancellationToken)
 {
     CreateCommandRequest = createCommandRequest;
     CancellationToken    = cancellationToken;
 }
Beispiel #11
0
 public ExecuteReaderRequest(CreateCommandRequest createCommandRequest)
     : this(createCommandRequest, CommandBehavior.Default, CancellationToken.None)
 {
 }