/// <summary>
        /// Performs tasks associated with freeing, releasing, or resetting resources.
        /// </summary>
        public override void Dispose()
        {
            DbDataReader reader = _reader;

            _reader = null;
            _nextResultGenerator = null;

            if (null != reader && _readerOwned)
            {
                reader.Dispose();
                if (_onReaderDispose != null)
                {
                    _onReaderDispose(this, new EventArgs());
                    _onReaderDispose = null;
                }
            }
            if (_shaper != null)
            {
                // This case includes when the ObjectResult is disposed before it
                // created an ObjectQueryEnumeration; at this time, the connection can be released
                if (_shaper.Context != null && _readerOwned)
                {
                    _shaper.Context.ReleaseConnection();
                }
                _shaper = null;
            }
        }
 internal ObjectResult(Shaper <T> shaper, EntitySet singleEntitySet, TypeUsage resultItemType, bool readerOwned, NextResultGenerator nextResultGenerator, Action <object, EventArgs> onReaderDispose)
 {
     _shaper              = shaper;
     _reader              = _shaper.Reader;
     _singleEntitySet     = singleEntitySet;
     _resultItemType      = resultItemType;
     _readerOwned         = readerOwned;
     _nextResultGenerator = nextResultGenerator;
     _onReaderDispose     = onReaderDispose;
 }