Beispiel #1
0
        protected override async Task <DbDataReader> ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
        {
            VerifyValid();
            Connection.HasActiveReader = true;

            MySqlDataReader reader = null;

            try
            {
                LastInsertedId = -1;
                var connection = (MySqlConnection)DbConnection;
                var preparer   = new MySqlStatementPreparer(CommandText, m_parameterCollection, connection.AllowUserVariables ? StatementPreparerOptions.AllowUserVariables : StatementPreparerOptions.None);
                preparer.BindParameters();
                var payload = new PayloadData(new ArraySegment <byte>(Payload.CreateEofStringPayload(CommandKind.Query, preparer.PreparedSql)));
                await Session.SendAsync(payload, cancellationToken).ConfigureAwait(false);

                reader = await MySqlDataReader.CreateAsync(this, behavior, cancellationToken).ConfigureAwait(false);

                return(reader);
            }
            finally
            {
                if (reader == null)
                {
                    // received an error from MySQL and never created an active reader
                    Connection.HasActiveReader = false;
                }
            }
        }
Beispiel #2
0
        internal async Task <DbDataReader> ExecuteReaderAsync(CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken)
        {
            VerifyValid();
            Connection.HasActiveReader = true;

            MySqlDataReader reader = null;

            try
            {
                LastInsertedId = -1;
                var connection = (MySqlConnection)DbConnection;
                var statementPreparerOptions = StatementPreparerOptions.None;
                if (connection.AllowUserVariables)
                {
                    statementPreparerOptions |= StatementPreparerOptions.AllowUserVariables;
                }
                if (connection.OldGuids)
                {
                    statementPreparerOptions |= StatementPreparerOptions.OldGuids;
                }
                var preparer = new MySqlStatementPreparer(CommandText, m_parameterCollection, statementPreparerOptions);
                var payload  = new PayloadData(preparer.ParseAndBindParameters());
                await Session.SendAsync(payload, ioBehavior, cancellationToken).ConfigureAwait(false);

                reader = await MySqlDataReader.CreateAsync(this, behavior, ioBehavior, cancellationToken).ConfigureAwait(false);

                return(reader);
            }
            finally
            {
                if (reader == null)
                {
                    // received an error from MySQL and never created an active reader
                    Connection.HasActiveReader = false;
                }
            }
        }
Beispiel #3
0
 public ParameterSqlParser(MySqlStatementPreparer preparer, BinaryWriter writer)
 {
     m_preparer = preparer;
     m_writer   = writer;
 }
 public ParameterSqlParser(MySqlStatementPreparer preparer)
 {
     m_preparer = preparer;
     Output = new StringBuilder();
 }
		protected override async Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
		{
			VerifyValid();
			Connection.HasActiveReader = true;

			MySqlDataReader reader = null;
			try
			{
				LastInsertedId = -1;
				var connection = (MySqlConnection) DbConnection;
				var statementPreparerOptions = StatementPreparerOptions.None;
				if (connection.AllowUserVariables)
					statementPreparerOptions |= StatementPreparerOptions.AllowUserVariables;
				if (connection.OldGuids)
					statementPreparerOptions |= StatementPreparerOptions.OldGuids;
				var preparer = new MySqlStatementPreparer(CommandText, m_parameterCollection, statementPreparerOptions);
				preparer.BindParameters();
				var payload = new PayloadData(new ArraySegment<byte>(Payload.CreateEofStringPayload(CommandKind.Query, preparer.PreparedSql)));
				await Session.SendAsync(payload, cancellationToken).ConfigureAwait(false);
				reader = await MySqlDataReader.CreateAsync(this, behavior, cancellationToken).ConfigureAwait(false);
				return reader;
			}
			finally
			{
				if (reader == null)
				{
					// received an error from MySQL and never created an active reader
					Connection.HasActiveReader = false;
				}
			}
		}
 public ParameterSqlParser(MySqlStatementPreparer preparer)
 {
     m_preparer = preparer;
     Output     = new StringBuilder();
 }