Esempio n. 1
0
        public static ExecuteReaderResponse <T1, T2> ExecuteReader <T1, T2>(this IDbCommandExecutor executor, ExecuteReaderRequest request,
                                                                            Func <IDataRecord, T1> read1, Func <IDataRecord, T2> read2)
        {
            ExecuteReaderResponse <T1, T2> response = null;

            executor.ExecuteReader(request, dataReader => response = dataReader.Read(() => read1(dataReader), () => read2(dataReader)));
            return(response);
        }
Esempio n. 2
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);
        }
        public static ExecuteReaderResponse <T1, T2> Read <T1, T2>(this IDataReader dataReader, Func <T1> read1, Func <T2> read2)
        {
            List <T1> result1 = null;
            List <T2> result2 = null;

            var readRecords = new Action[]
            {
                () => result1 = dataReader.ReadResult(read1),
                () => result2 = dataReader.ReadResult(read2)
            };

            dataReader.ReadResults(readRecords);

            return(ExecuteReaderResponse.Create(result1, result2));
        }
Esempio n. 4
0
        public static async Task <ExecuteReaderResponse <T1, T2> > ReadAsync <T1, T2>(
            this DbDataReader dataReader,
            Func <IDataRecord, T1> read1,
            Func <IDataRecord, T2> read2,
            CancellationToken cancellationToken)
        {
            List <T1> objects1 = null;
            List <T2> objects2 = null;

            var readResults = new Func <Task>[]
            {
                async() => objects1 = await dataReader.ReadAsync(read1, cancellationToken),
                async() => objects2 = await dataReader.ReadAsync(read2, cancellationToken),
            };

            await dataReader.ReadAsync(readResults, cancellationToken);

            return(ExecuteReaderResponse.Create(objects1, objects2));
        }