Google.Cloud.Spanner.Data - Class SpannerCommandTextBuilder (4.6.0)

public sealed class SpannerCommandTextBuilder

Reference documentation and code samples for the Google.Cloud.Spanner.Data class SpannerCommandTextBuilder.

Builds the CommandText string for executing a query or operation on a Spanner database. Instances are constructed with static factory methods.

Inheritance

object > SpannerCommandTextBuilder

Namespace

Google.Cloud.Spanner.Data

Assembly

Google.Cloud.Spanner.Data.dll

Properties

CommandText

public string CommandText { get; }

Gets the resulting string to be used for CommandText.

Property Value
TypeDescription
string

ExtraStatements

public IReadOnlyList<string> ExtraStatements { get; }

A set of additional statements to execute if supported by the command.

Property Value
TypeDescription
IReadOnlyListstring

ReadOptions

public ReadOptions ReadOptions { get; }

The read options for this command if the command is Read, or null otherwise.

Property Value
TypeDescription
ReadOptions

SpannerCommandType

public SpannerCommandType SpannerCommandType { get; }

Gets the type of Spanner command (Select, Read, Update, Delete, InsertOrUpdate, Insert, Ddl, Dml).

Property Value
TypeDescription
SpannerCommandType

TargetTable

public string TargetTable { get; }

Returns the target Spanner database table if the command is Read, Update, Delete, InsertOrUpdate, or Insert, or null otherwise.

Property Value
TypeDescription
string

Methods

CreateDdlTextBuilder(string, params string[])

public static SpannerCommandTextBuilder CreateDdlTextBuilder(string ddlStatement, params string[] extraDdlStatements)

Creates a SpannerCommandTextBuilder instance that generates CommandText for executing a DDL statement.

Parameters
NameDescription
ddlStatementstring

The full DDL statement. Must not be null.

extraDdlStatementsstring

An optional set of additional DDL statements to execute after the first statement. Extra Ddl statements cannot be used to create additional databases.

Returns
TypeDescription
SpannerCommandTextBuilder

A SpannerCommandTextBuilder representing a SpannerCommandType.Ddl Spanner command.

CreateDeleteTextBuilder(string)

public static SpannerCommandTextBuilder CreateDeleteTextBuilder(string table)

Creates a SpannerCommandTextBuilder instance that generates CommandText for deleting rows.

Parameter
NameDescription
tablestring

The name of the Spanner database table from which rows will be deleted. Must not be null.

Returns
TypeDescription
SpannerCommandTextBuilder

A SpannerCommandTextBuilder representing a SpannerCommandType.Delete Spanner command.

CreateDmlTextBuilder(string)

public static SpannerCommandTextBuilder CreateDmlTextBuilder(string dmlStatement)

Creates a SpannerCommandTextBuilder instance that generates CommandText for querying rows via a SQL query.

Parameter
NameDescription
dmlStatementstring

The full SQL query. Must not be null or empty.

Returns
TypeDescription
SpannerCommandTextBuilder

A SpannerCommandTextBuilder representing a SpannerCommandType.Select Spanner command.

CreateInsertOrUpdateTextBuilder(string)

public static SpannerCommandTextBuilder CreateInsertOrUpdateTextBuilder(string table)

Creates a SpannerCommandTextBuilder instance that generates CommandText for inserting or updating rows.

Parameter
NameDescription
tablestring

The name of the Spanner database table from which rows will be updated or inserted. Must not be null.

Returns
TypeDescription
SpannerCommandTextBuilder

A SpannerCommandTextBuilder representing a SpannerCommandType.InsertOrUpdate Spanner command.

CreateInsertTextBuilder(string)

public static SpannerCommandTextBuilder CreateInsertTextBuilder(string table)

Creates a SpannerCommandTextBuilder instance that generates CommandText for inserting rows.

Parameter
NameDescription
tablestring

The name of the Spanner database table from which rows will be inserted. Must not be null.

Returns
TypeDescription
SpannerCommandTextBuilder

A SpannerCommandTextBuilder representing a SpannerCommandType.Insert Spanner command.

CreateSelectTextBuilder(string)

public static SpannerCommandTextBuilder CreateSelectTextBuilder(string sqlQuery)

Creates a SpannerCommandTextBuilder instance that generates CommandText for querying rows via a SQL query.

Parameter
NameDescription
sqlQuerystring

The full SQL query. Must not be null or empty.

Returns
TypeDescription
SpannerCommandTextBuilder

A SpannerCommandTextBuilder representing a SpannerCommandType.Select Spanner command.

CreateUpdateTextBuilder(string)

public static SpannerCommandTextBuilder CreateUpdateTextBuilder(string table)

Creates a SpannerCommandTextBuilder instance that generates CommandText for updating rows.

Parameter
NameDescription
tablestring

The name of the Spanner database table from which rows will be updated. Must not be null.

Returns
TypeDescription
SpannerCommandTextBuilder

A SpannerCommandTextBuilder representing a SpannerCommandType.Update Spanner command.

FromCommandText(string)

public static SpannerCommandTextBuilder FromCommandText(string commandText)

Creates a SpannerCommandTextBuilder instance by parsing existing command text. The given text will be analyzed to choose the proper SpannerCommandType.

Parameter
NameDescription
commandTextstring

The full command text containing a query, DDL statement or insert/update/delete operation. The given text will be parsed and validated. Must not be null.

Returns
TypeDescription
SpannerCommandTextBuilder

A SpannerCommandTextBuilder whose SpannerCommandType is determined from parsing commandText.

Remarks

If the intended SpannerCommandType is Select, then commandText should be a SQL Query. If the intended SpannerCommandType is Ddl, then this string should be the DDL statement (eg 'CREATE TABLE MYTABLE...') If the intended SpannerCommandType is Update, Delete, InsertOrUpdate, or Insert, then the text should be '[spanner command type] [table name]' such as 'INSERT MYTABLE'. Must not be null or empty.

Exceptions
TypeDescription
ArgumentException

commandText is not formatted correctly.

ToString()

public override string ToString()
Returns
TypeDescription
string
Overrides