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.
Namespace
Google.Cloud.Spanner.DataAssembly
Google.Cloud.Spanner.Data.dll
Properties
CommandText
public string CommandText { get; }
Gets the resulting string to be used for CommandText.
Property Value | |
---|---|
Type | Description |
String |
ExtraStatements
public IReadOnlyList<string> ExtraStatements { get; }
A set of additional statements to execute if supported by the command.
Property Value | |
---|---|
Type | Description |
IReadOnlyList<String> |
ReadOptions
public ReadOptions ReadOptions { get; }
The read options for this command if the command is Read, or null otherwise.
Property Value | |
---|---|
Type | Description |
ReadOptions |
SpannerCommandType
public SpannerCommandType SpannerCommandType { get; }
Gets the type of Spanner command (Select, Read, Update, Delete, InsertOrUpdate, Insert, Ddl, Dml).
Property Value | |
---|---|
Type | Description |
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 | |
---|---|
Type | Description |
String |
Methods
CreateDdlTextBuilder(String, String[])
public static SpannerCommandTextBuilder CreateDdlTextBuilder(string ddlStatement, params string[] extraDdlStatements)
Creates a SpannerCommandTextBuilder instance that generates CommandText for executing a DDL statement.
Parameters | |
---|---|
Name | Description |
ddlStatement | String The full DDL statement. Must not be null. |
extraDdlStatements | String[] An optional set of additional DDL statements to execute after the first statement. Extra Ddl statements cannot be used to create additional databases. |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
table | String The name of the Spanner database table from which rows will be deleted. Must not be null. |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
dmlStatement | String The full SQL query. Must not be null or empty. |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
table | String The name of the Spanner database table from which rows will be updated or inserted. Must not be null. |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
table | String The name of the Spanner database table from which rows will be inserted. Must not be null. |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
sqlQuery | String The full SQL query. Must not be null or empty. |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
table | String The name of the Spanner database table from which rows will be updated. Must not be null. |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
commandText | String 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 | |
---|---|
Type | Description |
SpannerCommandTextBuilder | A SpannerCommandTextBuilder whose SpannerCommandType is determined
from parsing |
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 | |
---|---|
Type | Description |
ArgumentException |
|
ToString()
public override string ToString()
Returns | |
---|---|
Type | Description |
String |