/// <summary>
 /// Initializes a new instance of <see cref="SpannerCommand"/>
 /// </summary>
 /// <param name="commandText">If this command is a SQL Query, then commandText is
 /// the SQL statement. If its an update, insert or delete command, then this text
 /// is "[operation] [table]" such as "UPDATE MYTABLE"</param>. Must not be null.
 /// <param name="connection">The <see cref="SpannerConnection"/> that is
 /// associated with this <see cref="SpannerCommand"/>. Must not be null.</param>
 /// <param name="transaction">An optional <see cref="SpannerTransaction"/>
 /// created through <see>
 /// <cref>SpannerConnection.BeginTransactionAsync</cref></see>. May be null.</param>
 /// <param name="parameters">An optional collection of <see cref="SpannerParameter"/>
 /// that is used in the command. May be null.</param>
 public SpannerCommand(
     string commandText,
     SpannerConnection connection,
     SpannerTransaction transaction        = null,
     SpannerParameterCollection parameters = null)
     : this(SpannerCommandTextBuilder.FromCommandText(commandText), connection, transaction, parameters)
 {
 }
Beispiel #2
0
 internal SpannerCommand(string commandText, SpannerParameterCollection parameters = null)
 {
     SpannerCommandTextBuilder = SpannerCommandTextBuilder.FromCommandText(commandText);
     if (parameters != null)
     {
         Parameters = parameters;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of <see cref="SpannerCommand"/>.
 /// </summary>
 /// <param name="connection">The <see cref="SpannerConnection"/> that is
 /// associated with this <see cref="SpannerCommand"/>. Must not be null.</param>
 /// <param name="transaction">The <see cref="SpannerTransaction"/>
 /// used when creating the <see cref="CommandPartition"/>.
 /// </param>
 /// <param name="commandPartition">
 /// The partition which this command is restricted to.
 /// See <see cref="SpannerConnection.BeginReadOnlyTransaction(TransactionId)"/>
 /// </param>
 public SpannerCommand(
     SpannerConnection connection,
     SpannerTransaction transaction,
     CommandPartition commandPartition)
     : this(connection, transaction, null, commandPartition)
 {
     GaxPreconditions.CheckNotNull(connection, nameof(connection));
     GaxPreconditions.CheckNotNull(transaction, nameof(transaction));
     GaxPreconditions.CheckNotNull(commandPartition, nameof(commandPartition));
     SpannerCommandTextBuilder = SpannerCommandTextBuilder.FromCommandText(commandPartition.ExecuteSqlRequest.Sql);
 }
        /// <summary>
        /// Initializes a new instance of <see cref="SpannerCommand"/>.
        /// </summary>
        /// <param name="commandTextBuilder">The <see cref="SpannerCommandTextBuilder"/>
        /// that configures the text of this command. Must not be null.</param>
        /// <param name="connection">The <see cref="SpannerConnection"/> that is
        /// associated with this <see cref="SpannerCommand"/>. Must not be null.</param>
        /// <param name="transaction">An optional <see cref="SpannerTransaction"/>
        /// created through <see>
        /// <cref>SpannerConnection.BeginTransactionAsync</cref>
        /// </see>
        /// </param>. May be null.
        /// <param name="parameters">An optional collection of <see cref="SpannerParameter"/>
        /// that is used in the command. May be null.</param>
        public SpannerCommand(
            SpannerCommandTextBuilder commandTextBuilder,
            SpannerConnection connection,
            SpannerTransaction transaction        = null,
            SpannerParameterCollection parameters = null)
            : this(connection, transaction, parameters)
        {
            GaxPreconditions.CheckNotNull(commandTextBuilder, nameof(commandTextBuilder));
            GaxPreconditions.CheckNotNull(connection, nameof(connection));

            SpannerCommandTextBuilder = commandTextBuilder;
        }
 /// <summary>
 /// Initializes a new instance of <see cref="SpannerCommand"/> for a read operation.
 /// </summary>
 /// <remarks>
 /// The initial command timeout is taken from the options associated with <paramref name="connection"/>.
 /// </remarks>
 /// <param name="commandTextBuilder">The <see cref="SpannerCommandTextBuilder"/>
 /// that configures the text of this command. Must be a read command and not be null.</param>
 /// <param name="connection">The <see cref="SpannerConnection"/> that is
 /// associated with this <see cref="SpannerCommand"/>. Must not be null.</param>
 /// <param name="keySet">The <see cref="KeySet"/> that is used to select rows. Must not be null.</param>
 /// <param name="transaction">An optional <see cref="SpannerTransaction"/>
 /// created through <see cref="SpannerConnection.BeginTransactionAsync" />. May be null.</param>
 internal SpannerCommand(
     SpannerCommandTextBuilder commandTextBuilder,
     SpannerConnection connection,
     KeySet keySet,
     SpannerTransaction transaction = null)
     : this(connection, transaction, null, null)
 {
     GaxPreconditions.CheckArgument(commandTextBuilder.SpannerCommandType == SpannerCommandType.Read,
                                    nameof(commandTextBuilder.SpannerCommandType), "KeySet is only allowed for Read commands");
     SpannerCommandTextBuilder = GaxPreconditions.CheckNotNull(commandTextBuilder, nameof(commandTextBuilder));
     KeySet = GaxPreconditions.CheckNotNull(keySet, nameof(keySet));
 }
 /// <summary>
 /// Initializes a new instance of <see cref="SpannerCommand"/>.
 /// </summary>
 /// <param name="connection">The <see cref="SpannerConnection"/> that is
 /// associated with this <see cref="SpannerCommand"/>. Must not be null.</param>
 /// <param name="transaction">The <see cref="SpannerTransaction"/>
 /// used when creating the <see cref="CommandPartition"/>.
 /// </param>
 /// <param name="commandPartition">
 /// The partition which this command is restricted to.
 /// See <see cref="SpannerConnection.BeginReadOnlyTransaction(TransactionId)"/>
 /// </param>
 public SpannerCommand(
     SpannerConnection connection,
     SpannerTransaction transaction,
     CommandPartition commandPartition)
     : this(connection, transaction, null, commandPartition)
 {
     GaxPreconditions.CheckNotNull(connection, nameof(connection));
     GaxPreconditions.CheckNotNull(transaction, nameof(transaction));
     GaxPreconditions.CheckNotNull(commandPartition, nameof(commandPartition));
     SpannerCommandTextBuilder = commandPartition.Request.IsQuery
         ? SpannerCommandTextBuilder.FromCommandText(commandPartition.Request.ExecuteSqlRequest.Sql)
         : SpannerCommandTextBuilder.CreateReadTextBuilder(
         commandPartition.Request.ReadRequest.Table,
         ReadOptions.FromColumns(commandPartition.Request.ReadRequest.Columns));
 }