private static IEnumerable <TResult> SubqueryMaterialize <TResult>(IEnumerable <TResult> materializedSequence, ParameterContext parameterContext) { ParameterScope scope = null; var batchSequence = materializedSequence .Batch(BatchFastFirstCount, BatchMinSize, BatchMaxSize) .ApplyBeforeAndAfter( () => scope = parameterContext.Activate(), () => scope.DisposeSafely()); return(batchSequence.SelectMany(batch => batch)); }
public void Deactivate() { try { while (materializationQueue.Count > 0) { var materializeSelf = materializationQueue.Dequeue(); materializeSelf.Invoke(); } } finally { scope.DisposeSafely(); } }