/// <inheritdoc /> public override void Close() { EnsureInitialized(); // Make sure we explicitly closed the data record, since that's what // where using to track closed state. _dataRecord.CloseExplicitly(); if (!_isClosed) { _isClosed = true; if (0 == _dataRecord.Depth) { // If we're the root collection, we want to ensure the remainder of // the result column hierarchy is closed out, to avoid dangling // references to it, should it be reused. We also want to physically // close out the source reader as well. _shaper.Reader.Close(); } else { // For non-root collections, we have to consume all the data, or we'll // not be positioned propertly for what comes afterward. Consume(); } } if (_nextResultShaperInfoEnumerator != null) { _nextResultShaperInfoEnumerator.Dispose(); _nextResultShaperInfoEnumerator = null; } }