public virtual IEnumerable <IDataRecord> ExecutePagedQuery(string queryText, NextPageDelegate nextpage)
        {
            int pageSize = _dialect.CanPage ? PageSize : InfinitePageSize;

            if (pageSize > 0)
            {
                Logger.Verbose(Messages.MaxPageSize, pageSize);
                Parameters.Add(_dialect.Limit, Tuple.Create((object)pageSize, (DbType?)null));
            }

            return(ExecuteQuery(queryText, nextpage, pageSize));
        }
Beispiel #2
0
        public virtual IEnumerable <IDataRecord> ExecutePagedQuery(string queryText, NextPageDelegate nextpage)
        {
            var pageSize = this.dialect.CanPage ? this.PageSize : InfinitePageSize;

            if (pageSize > 0)
            {
                Logger.Verbose(Messages.MaxPageSize, pageSize);
                this.Parameters.Add(this.dialect.Limit, pageSize);
            }

            return(this.ExecuteQuery(queryText, nextpage, pageSize));
        }
 public PagedEnumerationCollection(
     TransactionScope scope,
     ISqlDialect dialect,
     IDbCommand command,
     NextPageDelegate nextpage,
     int pageSize,
     params IDisposable[] disposable)
 {
     _scope      = scope;
     _dialect    = dialect;
     _command    = command;
     _nextpage   = nextpage;
     _pageSize   = pageSize;
     _disposable = disposable ?? _disposable;
 }
 public PagedEnumerationCollection(
     IDbCommand command,
     Func <IDataRecord, T> select,
     NextPageDelegate <T> onNextPage,
     int pageSize,
     TransactionScope scope,
     params IDisposable[] disposable)
 {
     this.command    = command;
     this.select     = select;
     this.onNextPage = onNextPage;
     this.pageSize   = pageSize;
     this.scope      = scope;
     this.disposable = disposable ?? this.disposable;
 }
        protected virtual IEnumerable <IDataRecord> ExecuteQuery(string queryText, NextPageDelegate nextpage, int pageSize)
        {
            Parameters.Add(_dialect.Skip, Tuple.Create((object)0, (DbType?)null));
            IDbCommand command = BuildCommand(queryText);

            try
            {
                return(new PagedEnumerationCollection(_scope, _dialect, command, nextpage, pageSize, this));
            }
            catch (Exception)
            {
                command.Dispose();
                throw;
            }
        }
Beispiel #6
0
        protected virtual IEnumerable <IDataRecord> ExecuteQuery(string queryText, NextPageDelegate nextpage, int pageSize)
        {
            this.Parameters.Add(this.dialect.Skip, 0);
            var command = this.BuildCommand(queryText);

            try
            {
                return(new PagedEnumerationCollection(this.scope, this.dialect, command, nextpage, pageSize, this));
            }
            catch (Exception)
            {
                command.Dispose();
                throw;
            }
        }
Beispiel #7
0
        public virtual IEnumerable <T> ExecutePagedQuery <T>(
            string queryText, Func <IDataRecord, T> select, NextPageDelegate <T> onNextPage, int pageSize)
        {
            pageSize = this.dialect.CanPage ? pageSize : InfinitePageSize;
            if (pageSize > 0)
            {
                Logger.Verbose(Messages.MaxPageSize, pageSize);
                this.Parameters.Add(this.dialect.Limit, pageSize);
            }

            var command = this.BuildCommand(queryText);

            try
            {
                return(new PagedEnumerationCollection <T>(
                           command, select, onNextPage, pageSize, this.scope, this));
            }
            catch (Exception)
            {
                command.Dispose();
                throw;
            }
        }
 public IEnumerable <IDataRecord> ExecutePagedQuery(string queryText, NextPageDelegate nextpage)
 {
     _recorder.RecordIsolationLevel(queryText, GetCurrentIsolationLevel());
     return(_innerStatement.ExecutePagedQuery(queryText, nextpage));
 }
        public virtual IEnumerable<IDataRecord> ExecutePagedQuery(string queryText, NextPageDelegate nextpage)
        {
            var pageSize = this.dialect.CanPage ? this.PageSize : InfinitePageSize;
            if (pageSize > 0)
            {
                Logger.Verbose(Messages.MaxPageSize, pageSize);
                this.Parameters.Add(this.dialect.Limit, pageSize);
            }

            return this.ExecuteQuery(queryText, nextpage, pageSize);
        }
        protected virtual IEnumerable<IDataRecord> ExecuteQuery(string queryText, NextPageDelegate nextpage, int pageSize)
        {
            this.Parameters.Add(this.dialect.Skip, 0);
            var command = this.BuildCommand(queryText);

            try
            {
                return new PagedEnumerationCollection(this.scope, this.dialect, command, nextpage, pageSize, this);
            }
            catch (Exception)
            {
                command.Dispose();
                throw;
            }
        }
        protected virtual IEnumerable<IDataRecord> ExecuteQuery(string queryText, NextPageDelegate nextpage, int pageSize)
        {
            Parameters.Add(_dialect.Skip, Tuple.Create((object) 0, (DbType?) null));
            IDbCommand command = BuildCommand(queryText);

            try
            {
                return new PagedEnumerationCollection(_scope, _dialect, command, nextpage, pageSize, this);
            }
            catch (Exception)
            {
                command.Dispose();
                throw;
            }
        }
        public virtual IEnumerable<IDataRecord> ExecutePagedQuery(string queryText, NextPageDelegate nextpage)
        {
            int pageSize = _dialect.CanPage ? PageSize : InfinitePageSize;
            if (pageSize > 0)
            {
                Logger.Verbose(Messages.MaxPageSize, pageSize);
                Parameters.Add(_dialect.Limit, Tuple.Create((object) pageSize, (DbType?) null));
            }

            return ExecuteQuery(queryText, nextpage, pageSize);
        }
        protected virtual IAsyncEnumerable<IDataRecord> ExecuteQuery(string queryText, NextPageDelegate nextpage, int pageSize)
        {
            Parameters.Add(_dialect.Skip, Tuple.Create((object)0, (DbType?)null));
            return AsyncEnumerable.Create<IDataRecord>(async producer =>
            {
                using (var command = BuildCommand(queryText))
                {
                    var position = 0;
                    var read = 0;
                    try
                    { 
                        do
                        {
                            using (var reader = await command.ExecuteReaderAsync())
                            {
                                read = 0;
                                while (await reader.ReadAsync())
                                {
                                    await producer.Yield(reader);
                                    position++;
                                    read++;

                                    if (IsPageCompletelyEnumerated(pageSize, position))
                                    {
                                        command.SetParameter(_dialect.Skip, position);
                                        nextpage(command, reader);
                                    }
                                }
                                Logger.Verbose(Messages.EnumeratedRowCount, position);
                            }
                        }
                        while (read > 0 && IsPageCompletelyEnumerated(pageSize,position));
                        
                    }
                    catch (Exception e)
                    {
                        Logger.Debug(Messages.EnumerationThrewException, e.GetType());
                        throw new StorageUnavailableException(e.Message, e);
                    }
                }
            });
            
        }
Beispiel #14
0
        protected virtual IAsyncEnumerable <IDataRecord> ExecuteQuery(string queryText, NextPageDelegate nextpage, int pageSize)
        {
            Parameters.Add(_dialect.Skip, Tuple.Create((object)0, (DbType?)null));
            return(AsyncEnumerable.Create <IDataRecord>(async producer =>
            {
                using (var command = BuildCommand(queryText))
                {
                    var position = 0;
                    var read = 0;
                    try
                    {
                        do
                        {
                            using (var reader = await command.ExecuteReaderAsync())
                            {
                                read = 0;
                                while (await reader.ReadAsync())
                                {
                                    await producer.Yield(reader);
                                    position++;
                                    read++;

                                    if (IsPageCompletelyEnumerated(pageSize, position))
                                    {
                                        command.SetParameter(_dialect.Skip, position);
                                        nextpage(command, reader);
                                    }
                                }
                                Logger.Verbose(Messages.EnumeratedRowCount, position);
                            }
                        }while (read > 0 && IsPageCompletelyEnumerated(pageSize, position));
                    }
                    catch (Exception e)
                    {
                        Logger.Debug(Messages.EnumerationThrewException, e.GetType());
                        throw new StorageUnavailableException(e.Message, e);
                    }
                }
            }));
        }