internal virtual IEnumerable QueryDataReader(IDataDefine source, IDbCommand dbcommand, Region region, SafeLevel level) { int start; int size; if (region != null) { start = region.Start; size = region.Size; } else { start = 0; size = int.MaxValue; } using (TransactionConnection transaction = CreateTransactionConnection(level)) { transaction.Open(); transaction.SetupCommand(dbcommand); using (IDataReader reader = dbcommand.ExecuteReader()) { int index = 0; int count = 0; bool over = false; while (reader.Read()) { if (over) { dbcommand.Cancel(); break; } if (index >= start) { count++; object item = source.LoadData(this, reader); if (count >= size) { over = true; } yield return(item); } index++; } } transaction.Commit(); } }
internal override IEnumerable QueryDataReader(IDataDefine source, IDbCommand dbcommand, Region region, SafeLevel level) { int start; int size; if (region != null) { start = region.Start; size = region.Size; } else { start = 0; size = int.MaxValue; } if (_isTransaction) { _trconnection.SetupCommand(dbcommand); using (IDataReader reader = dbcommand.ExecuteReader()) { int index = 0; int count = 0; while (reader.Read()) { if (index >= start) { count++; object item = source.LoadData(this, reader); yield return(item); if (count >= size) { dbcommand.Cancel(); break; } } index++; } } } else { TransactionConnection transaction = GetTransactionConnection(); transaction.ResetTransaction(level); transaction.SetupCommand(dbcommand); using (IDataReader reader = dbcommand.ExecuteReader()) { int index = 0; int count = 0; while (reader.Read()) { if (index >= start) { count++; object item = source.LoadData(this, reader); yield return(item); if (count >= size) { dbcommand.Cancel(); break; } } index++; } } transaction.Commit(); } }