示例#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);
        }
示例#2
0
        public static List <T> ExecuteReader <T>(this IDbCommandExecutor executor, ExecuteReaderRequest request, Func <IDataRecord, T> read)
        {
            List <T> rows = null;

            executor.ExecuteReader(request, dataReader => rows = dataReader.ReadResult(() => read(dataReader)));
            return(rows);
        }
示例#3
0
        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);
        }
示例#4
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);
     });
 }
示例#5
0
        public static ReadOnlySegmentLinkedList <T> ExecuteReader <T>(this DbProviderFactory dbProviderFactory, string connectionString,
                                                                      ExecuteReaderRequest request, int segmentLength, Func <IDataRecord, T> readRecord)
        {
            ReadOnlySegmentLinkedList <T> rows = null;

            dbProviderFactory.ExecuteReader(connectionString, request, dataReader => rows = dataReader.ReadResult(segmentLength, readRecord));
            return(rows);
        }
示例#6
0
 public static Task ExecuteReaderAsync(this IDbCommandAsyncExecutor executor, ExecuteReaderRequest request, Func <DbDataReader, Task> readResults)
 {
     return(executor.ExecuteAsync(
                new ExecuteNonReaderRequest(request.CreateCommandRequest, request.CancellationToken),
                async command =>
     {
         using (var dataReader = await command.ExecuteReaderAsync(request.CommandBehavior, request.CancellationToken))
             await readResults(dataReader);
     }));
 }
示例#7
0
        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);
            });
        }
示例#8
0
        public static List <T> ExecuteReader <T>(
            this DbProviderFactory dbProviderFactory,
            string connectionString,
            ExecuteReaderRequest request,
            Func <IDataRecord, T> read)
        {
            List <T> rows = null;

            dbProviderFactory.ExecuteReader(connectionString, request, dataReader => rows = dataReader.ReadResult(read));
            return(rows);
        }
示例#9
0
 public static void ExecuteReader(
     this DbProviderFactory dbProviderFactory,
     string connectionString,
     ExecuteReaderRequest request,
     Action <IDataReader> read)
 {
     using (var connection = dbProviderFactory.CreateConnection())
     {
         connection.ConnectionString = connectionString;
         connection.Open();
         var executor = connection.CreateCommandExecutor();
         executor.ExecuteReader(request, read);
     }
 }
示例#10
0
        public static ExecuteReaderResponse <T1, T2, T3> ExecuteReader <T1, T2, T3>(this IDbCommandExecutor executor, ExecuteReaderRequest request,
                                                                                    Func <IDataRecord, T1> read1, Func <IDataRecord, T2> read2, Func <IDataRecord, T3> read3)
        {
            ExecuteReaderResponse <T1, T2, T3> response = null;

            executor.ExecuteReader(request,
                                   dataReader => response = dataReader.Read(() => read1(dataReader), () => read2(dataReader), () => read3(dataReader)));
            return(response);
        }
示例#11
0
        public static async Task <ReadOnlySegmentLinkedList <T> > ExecuteReaderAsync <T>(this IDbCommandAsyncExecutor executor, ExecuteReaderRequest request,
                                                                                         int segmentLength, Func <IDataRecord, T> read)
        {
            ReadOnlySegmentLinkedList <T> records = null;
            await executor.ExecuteReaderAsync(
                request,
                async dataReader => records = await dataReader.ReadResultAsync(segmentLength, read, request.CancellationToken));

            return(records);
        }
示例#12
0
        public static async Task <ExecuteReaderResponse <T1, T2, T3> > ExecuteReaderAsync <T1, T2, T3>(this IDbCommandAsyncExecutor executor,
                                                                                                       ExecuteReaderRequest request, Func <IDataRecord, T1> read1, Func <IDataRecord, T2> read2, Func <IDataRecord, T3> read3)
        {
            ExecuteReaderResponse <T1, T2, T3> response = null;
            await executor.ExecuteReaderAsync(
                request,
                async dataReader => response = await dataReader.ReadAsync(read1, read2, read3, request.CancellationToken));

            return(response);
        }
示例#13
0
        public static async Task <List <T> > ExecuteReaderAsync <T>(this IDbCommandAsyncExecutor executor, ExecuteReaderRequest request, Func <IDataRecord, T> read)
        {
            List <T> records = null;
            await executor.ExecuteReaderAsync(
                request,
                async dataReader => records = await dataReader.ReadAsync(read, request.CancellationToken));

            return(records);
        }
示例#14
0
        public static ReadOnlySegmentLinkedList <T> ExecuteReader <T>(this IDbCommandExecutor executor, ExecuteReaderRequest request, int segmentLength,
                                                                      Func <IDataRecord, T> readRecord)
        {
            Assert.IsNotNull(executor);
            ReadOnlySegmentLinkedList <T> rows = null;

            executor.ExecuteReader(request, dataReader => rows = dataReader.ReadResult(segmentLength, readRecord));
            return(rows);
        }