/// <summary> /// Run a Query but don't dispose the source, and return the count of rows from the query. /// </summary> /// <param name="pipeline">IXTable of source or query to run</param> /// <param name="cancellationToken">Token to allow early cancellation</param> /// <param name="batchSize">Number of rows to process on each iteration</param> /// <returns>Count of rows in this source or query.</returns> public static RunResult RunWithoutDispose(this IXTable pipeline, CancellationToken cancellationToken = default(CancellationToken), int batchSize = DefaultBatchSize) { RunResult result = new RunResult(); Stopwatch w = Stopwatch.StartNew(); while (true) { int batchCount = pipeline.Next(batchSize, cancellationToken); result.RowCount += batchCount; if (cancellationToken.IsCancellationRequested) { break; } else if (batchCount == 0) { result.IsComplete = true; break; } } result.Elapsed = w.Elapsed; return(result); }