internal ReaderEventSink(SqlDataReaderSmi reader, SmiEventSink parent) : base(parent) { this.reader = reader; }
private SqlDataReader RunExecuteReaderSmi(CommandBehavior cmdBehavior, RunBehavior runBehavior, bool returnStream) { SqlInternalConnectionSmi internalSmiConnection = this.InternalSmiConnection; SmiEventStream eventStream = null; SqlDataReader reader = null; try { long num; System.Transactions.Transaction transaction; this.SetUpSmiRequest(internalSmiConnection); internalSmiConnection.GetCurrentTransactionPair(out num, out transaction); if (Bid.AdvancedOn) { Bid.Trace("<sc.SqlCommand.RunExecuteReaderSmi|ADV> %d#, innerConnection=%d#, transactionId=0x%I64x, commandBehavior=%d.\n", this.ObjectID, internalSmiConnection.ObjectID, num, (int) cmdBehavior); } if (SmiContextFactory.Instance.NegotiatedSmiVersion >= 210L) { eventStream = this._smiRequest.Execute(internalSmiConnection.SmiConnection, num, transaction, cmdBehavior, SmiExecuteType.Reader); } else { eventStream = this._smiRequest.Execute(internalSmiConnection.SmiConnection, num, cmdBehavior, SmiExecuteType.Reader); } if ((runBehavior & RunBehavior.UntilDone) != ((RunBehavior) 0)) { while (eventStream.HasEvents) { eventStream.ProcessEvent(this.EventSink); } eventStream.Close(this.EventSink); } if (returnStream) { reader = new SqlDataReaderSmi(eventStream, this, cmdBehavior, internalSmiConnection, this.EventSink); reader.NextResult(); this._activeConnection.AddWeakReference(reader, 1); } this.EventSink.ProcessMessagesAndThrow(); } catch (Exception exception) { if (!ADP.IsCatchableOrSecurityExceptionType(exception)) { throw; } if (eventStream != null) { eventStream.Close(this.EventSink); } this.DisposeSmiRequest(); throw; } return reader; }