Class SpannerDataAdapter
Represents a set of data commands and a database connection that are used to fill the DataSet and update a Spanner database.
Inherited Members
Namespace: Google.Cloud.Spanner.Data
Assembly: Google.Cloud.Spanner.Data.dll
Syntax
public sealed class SpannerDataAdapter : DbDataAdapter, IComponent, IDisposable, ICloneable, IDbDataAdapter, IDataAdapter
Constructors
SpannerDataAdapter()
Initializes a new instance of the SpannerDataAdapter class
Declaration
public SpannerDataAdapter()
SpannerDataAdapter(SpannerConnection, string, params string[])
Initializes a new instance of the SpannerDataAdapter class with the specified
Declaration
public SpannerDataAdapter(SpannerConnection connection, string autoGeneratedCommandTable, params string[] primaryKeys)
Parameters
Type | Name | Description |
---|---|---|
SpannerConnection | connection | A connection to the Spanner database. Must not be null. |
string | autoGeneratedCommandTable | The Spanner database table to use for automatically generated commands. May be null. |
string[] | primaryKeys | The set of columns that form the primary key for
|
Properties
AutoGeneratedCommandPrimaryKeys
The set of primary keys defined for AutoGeneratedCommandTable.
Declaration
public ISet<string> AutoGeneratedCommandPrimaryKeys { get; }
Property Value
Type | Description |
---|---|
ISet<string> |
AutoGeneratedCommandTable
The table to use for automatically built commands. If set, the SpannerDataAdapter will automatically create commands for SelectCommand, InsertCommand, UpdateCommand and DeleteCommand selecting all columns for that Table. You can choose to customize some or all of the commands and use the autogenerated commands for ones you do not modify. For example, you can set SelectCommand to be a custom SQL Query, and leave the other commands to be based on AutoGeneratedCommandTable
Declaration
public string AutoGeneratedCommandTable { get; set; }
Property Value
Type | Description |
---|---|
string |
DeleteCommand
The SpannerCommand used to delete rows.
Declaration
public SpannerCommand DeleteCommand { get; set; }
Property Value
Type | Description |
---|---|
SpannerCommand |
InsertCommand
The SpannerCommand used to insert rows.
Declaration
public SpannerCommand InsertCommand { get; set; }
Property Value
Type | Description |
---|---|
SpannerCommand |
SelectCommand
The SpannerCommand used to run a SQL Query.
Declaration
public SpannerCommand SelectCommand { get; set; }
Property Value
Type | Description |
---|---|
SpannerCommand |
SpannerConnection
The connection to the Spanner database.
Declaration
public SpannerConnection SpannerConnection { get; set; }
Property Value
Type | Description |
---|---|
SpannerConnection |
UpdateCommand
The SpannerCommand used to update rows.
Declaration
public SpannerCommand UpdateCommand { get; set; }
Property Value
Type | Description |
---|---|
SpannerCommand |
Methods
CreateRowUpdatedEvent(DataRow, IDbCommand, StatementType, DataTableMapping)
Initializes a new instance of the RowUpdatedEventArgs class.
Declaration
protected override RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
Parameters
Type | Name | Description |
---|---|---|
DataRow | dataRow | The DataRow used to update the data source. |
IDbCommand | command | The IDbCommand executed during the Update(DataSet). |
StatementType | statementType | Whether the command is an UPDATE, INSERT, DELETE, or SELECT statement. |
DataTableMapping | tableMapping | A DataTableMapping object. |
Returns
Type | Description |
---|---|
RowUpdatedEventArgs | A new instance of the RowUpdatedEventArgs class. |
Overrides
CreateRowUpdatingEvent(DataRow, IDbCommand, StatementType, DataTableMapping)
Initializes a new instance of the RowUpdatingEventArgs class.
Declaration
protected override RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
Parameters
Type | Name | Description |
---|---|---|
DataRow | dataRow | The DataRow that updates the data source. |
IDbCommand | command | The IDbCommand to execute during the Update(DataSet). |
StatementType | statementType | Whether the command is an UPDATE, INSERT, DELETE, or SELECT statement. |
DataTableMapping | tableMapping | A DataTableMapping object. |
Returns
Type | Description |
---|---|
RowUpdatingEventArgs | A new instance of the RowUpdatingEventArgs class. |
Overrides
Fill(DataSet, int, int, string, IDbCommand, CommandBehavior)
Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and source table names, command string, and command behavior.
Declaration
protected override int Fill(DataSet dataSet, int startRecord, int maxRecords, string srcTable, IDbCommand command, CommandBehavior behavior)
Parameters
Type | Name | Description |
---|---|---|
DataSet | dataSet | A DataSet to fill with records and, if necessary, schema. |
int | startRecord | The zero-based record number to start with. |
int | maxRecords | The maximum number of records to retrieve. |
string | srcTable | The name of the source table to use for table mapping. |
IDbCommand | command | The SQL SELECT statement used to retrieve rows from the data source. |
CommandBehavior | behavior | One of the CommandBehavior values. |
Returns
Type | Description |
---|---|
int | The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The source table is invalid. |
ArgumentException | The |
Fill(DataSet, string, IDataReader, int, int)
Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and DataTable names.
Declaration
protected override int Fill(DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
Parameters
Type | Name | Description |
---|---|---|
DataSet | dataSet | A DataSet to fill with records. |
string | srcTable | A string indicating the name of the source table. |
IDataReader | dataReader | An instance of IDataReader. |
int | startRecord | The zero-based index of the starting record. |
int | maxRecords | An integer indicating the maximum number of records. |
Returns
Type | Description |
---|---|
int | The number of rows successfully added to or refreshed in the DataSet. This does not include rows affected by statements that do not return rows. |
Overrides
OnRowUpdated(RowUpdatedEventArgs)
Raises the RowUpdated
event of a .NET Framework data provider.
Declaration
protected override void OnRowUpdated(RowUpdatedEventArgs rowUpdatedEventArgs)
Parameters
Type | Name | Description |
---|---|---|
RowUpdatedEventArgs | rowUpdatedEventArgs |
Overrides
OnRowUpdating(RowUpdatingEventArgs)
Raises the RowUpdating
event of a .NET Framework data provider.
Declaration
protected override void OnRowUpdating(RowUpdatingEventArgs rowUpdatingEventArgs)
Parameters
Type | Name | Description |
---|---|---|
RowUpdatingEventArgs | rowUpdatingEventArgs |
Overrides
Events
RowUpdated
Occurs during Update after a command is executed against the data source.
Declaration
public event EventHandler<SpannerRowUpdatedEventArgs> RowUpdated
Event Type
Type | Description |
---|---|
EventHandler<SpannerRowUpdatedEventArgs> |
RowUpdating
Occurs during Update before a command is executed against the data source.
Declaration
public event EventHandler<SpannerRowUpdatingEventArgs> RowUpdating
Event Type
Type | Description |
---|---|
EventHandler<SpannerRowUpdatingEventArgs> |