/// <summary>Releases the unmanaged resources used by the <see cref="T:System.Data.Entity.Core.Objects.ObjectResult`1" /> and optionally releases the managed resources.</summary> /// <param name="disposing">true to release managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { DbDataReader reader = this._reader; this._reader = (DbDataReader)null; this._nextResultGenerator = (NextResultGenerator)null; if (reader != null && this._readerOwned) { reader.Dispose(); if (this._onReaderDispose != null) { this._onReaderDispose((object)this, new EventArgs()); this._onReaderDispose = (Action <object, EventArgs>)null; } } if (this._shaper != null) { if (this._shaper.Context != null && this._readerOwned && this._shouldReleaseConnection) { this._shaper.Context.ReleaseConnection(); } this._shaper = (Shaper <T>)null; } if (this._command == null) { return; } this._command.Dispose(); this._command = (DbCommand)null; }
protected override void Dispose(bool disposing) { var reader = _reader; _reader = null; _nextResultGenerator = null; if (reader != null && _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 && _shouldReleaseConnection) { _shaper.Context.ReleaseConnection(); } _shaper = null; } }
public override void Dispose() { // Technically, calling GC.SuppressFinalize is not required because the class does not // have a finalizer, but it does no harm, protects against the case where a finalizer is added // in the future, and prevents an FxCop warning. GC.SuppressFinalize(this); var 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; }
internal ObjectResult( Shaper <T> shaper, EntitySet singleEntitySet, TypeUsage resultItemType, bool readerOwned, bool shouldReleaseConnection, NextResultGenerator nextResultGenerator, Action <object, EventArgs> onReaderDispose, DbCommand command = null) { _shaper = shaper; _reader = _shaper.Reader; _command = command; _singleEntitySet = singleEntitySet; _resultItemType = resultItemType; _readerOwned = readerOwned; _shouldReleaseConnection = shouldReleaseConnection; _nextResultGenerator = nextResultGenerator; _onReaderDispose = onReaderDispose; }