Ejemplo n.º 1
0
        public static DataSet ExecuteDataSet(this IDbCommandExecutor executor, ExecuteReaderRequest request)
        {
            DataSet dataSet = null;

            executor.Execute(request.CreateCommandRequest, command => { dataSet = command.ExecuteDataSet(request.CancellationToken); });
            return(dataSet);
        }
    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);
    }
Ejemplo n.º 3
0
        public static int ExecuteNonQuery(this IDbCommandExecutor executor, CreateCommandRequest request)
        {
            var affectedRows = 0;

            executor.Execute(request, command => affectedRows = command.ExecuteNonQuery());
            return(affectedRows);
        }
Ejemplo n.º 4
0
        public static object ExecuteScalar(this IDbCommandExecutor executor, CreateCommandRequest request)
        {
            object scalar = null;

            executor.Execute(request, command => scalar = command.ExecuteScalar());
            return(scalar);
        }
    public static void Execute(this IDbCommandExecutor executor, CreateCommandRequest request, Action <IDbCommand> execute)
    {
        ArgumentNullException.ThrowIfNull(executor);
        var requests = new ExecuteCommandRequest(request, execute).ItemToArray();

        executor.Execute(requests);
    }
    public static DataTable ExecuteDataTable(this IDbCommandExecutor executor, ExecuteReaderRequest request)
    {
        Assert.IsNotNull(executor);
        DataTable dataTable = null;

        executor.Execute(request.CreateCommandRequest, command => { dataTable = command.ExecuteDataTable(request.CancellationToken); });
        return(dataTable);
    }
Ejemplo n.º 7
0
 public static void ExecuteReader(this IDbCommandExecutor executor, ExecuteReaderRequest request, Action <IDataReader> read)
 {
     executor.Execute(request.CreateCommandRequest, command =>
     {
         using (var dataReader = command.ExecuteReader(request.CommandBehavior))
             read(dataReader);
     });
 }
    public static object ExecuteScalar(this IDbCommandExecutor executor, CreateCommandRequest request)
    {
        ArgumentNullException.ThrowIfNull(executor);
        object scalar = null;

        executor.Execute(request, command => scalar = command.ExecuteScalar());
        return(scalar);
    }
    public static int ExecuteNonQuery(this IDbCommandExecutor executor, CreateCommandRequest request)
    {
        ArgumentNullException.ThrowIfNull(executor);
        var affectedRows = 0;

        executor.Execute(request, command => affectedRows = command.ExecuteNonQuery());
        return(affectedRows);
    }
Ejemplo n.º 10
0
        public static void Execute(this IDbCommandExecutor executor, CreateCommandRequest request, Action <IDbCommand> execute)
        {
            var requests = new[]
            {
                new ExecuteCommandRequest(request, execute)
            };

            executor.Execute(requests);
        }
    public static DataSet ExecuteDataSet(this IDbCommandExecutor executor, ExecuteReaderRequest request)
    {
        ArgumentNullException.ThrowIfNull(executor);
        ArgumentNullException.ThrowIfNull(request);
        DataSet dataSet = null;

        executor.Execute(request.CreateCommandRequest, command => { dataSet = command.ExecuteDataSet(request.CancellationToken); });
        return(dataSet);
    }
 public static object GetResultSync(this IDbCommandExecutor executor, DbCommandWrapper command)
 {
     executor.Execute(command).Wait();
     if (command.Ok)
     {
         return(command.Result);
     }
     throw command.Error;
 }
    public static void ExecuteReader(this IDbCommandExecutor executor, ExecuteReaderRequest request, Action <IDataReader> readResults)
    {
        Assert.IsNotNull(executor);
        Assert.IsNotNull(request);

        executor.Execute(request.CreateCommandRequest, command =>
        {
            using (var dataReader = command.ExecuteReader(request.CommandBehavior))
                readResults(dataReader);
        });
    }
Ejemplo n.º 14
0
 private static void Execute(this IDbCommandExecutor executor, IEnumerable <ExecuteCommandRequest> requests)
 {
     executor.Execute(connection =>
     {
         foreach (var request in requests)
         {
             using (var command = connection.CreateCommand(request.CreateCommandRequest))
                 request.Execute(command);
         }
     });
 }
    private static void Execute(this IDbCommandExecutor executor, IEnumerable <ExecuteCommandRequest> requests)
    {
        ArgumentNullException.ThrowIfNull(executor);

        executor.Execute(connection =>
        {
            foreach (var request in requests)
            {
                using (var command = connection.CreateCommand(request.CreateCommandRequest))
                    request.Execute(command);
            }
        });
    }