dotConnect for Google BigQuery Documentation
Devart.Data.BigQuery Namespace / BigQueryCommandBuilder Class
Members Example

On this page
    BigQueryCommandBuilder Class
    On this page
    Automatically generates single-table commands used to reconcile changes made to a System.Data.DataSet with the Google BigQuery.
    Syntax
    'Declaration
     
    Public Class BigQueryCommandBuilder 
       Inherits Devart.Data.SqlShimCommandBuilder
       Implements System.ComponentModel.IComponent, System.IDisposable 
    Remarks

    The BigQueryDataAdapter does not automatically generate the SQL statements required to reconcile changes made to a System.Data.DataSet associated with Google BigQuery. However, you can create a BigQueryCommandBuilder object that generates SQL statements for single-table updates. After assigning the BigQueryDataAdapter to the BigQueryCommandBuilder, it begins to generate any additional SQL statements that you do not set.

    The relationship between a BigQueryDataAdapter and its corresponding BigQueryCommandBuilder is always one-to-one. To create this correspondence, you set the DataAdapter property of the BigQueryCommandBuilder object. This causes the BigQueryCommandBuilder to register itself as a listener, which produces the output of BigQueryDataAdapter.RowUpdating events that affect the System.Data.DataSet.

    To generate INSERT, UPDATE, or DELETE statements, the BigQueryCommandBuilder uses the BigQueryDataAdapter.SelectCommand property to retrieve a required set of metadata. If you change the value of BigQueryDataAdapter.SelectCommand after the metadata has been retrieved (for example, after the first update), you then should call the Devart.Common.DbCommandBuilderBase.RefreshSchema method to update the metadata.

    The BigQueryCommandBuilder also uses the Connection, CommandTimeout, and System.Data.Common.DbCommand.Transaction properties referenced by the BigQueryDataAdapter.SelectCommand. The user should call Devart.Common.DbCommandBuilderBase.RefreshSchema if any of these properties are modified, or value of the BigQueryDataAdapter.SelectCommand property itself is changed. Otherwise the BigQueryDataAdapter.InsertCommand, BigQueryDataAdapter.UpdateCommand, and BigQueryDataAdapter.DeleteCommand properties retain their previous values.

    If you assign null to corresponding property of BigQueryDataAdapter, the BigQueryCommandBuilder will be disassociated from the BigQueryDataAdapter, and the generated commands will no longer be used.

    Note: This class is not available in .NET Standard 1.3 compatible assembly. It is available only in the assembly for full .NET Framework and .NET Standard 2.0 compatible assembly.

    Example
    The following example uses BigQueryCommand, along with BigQueryDataAdapter and BigQueryConnection, to select rows from Google BigQuery. The example is passed an initialized System.Data.DataSet, a connection string, a query string that is SQL SELECT statement, and a string that is the name of the Google BigQuery table. The example then creates a BigQueryCommandBuilder.
    public DataSet SelectBigQuerySrvRows(DataSet myDataSet,string bigQueryConnection,string mySelectQuery,string myTableName)
    {
      BigQueryConnection myConn = new BigQueryConnection(bigQueryConnection);
      BigQueryDataAdapter myDataAdapter = new BigQueryDataAdapter();
      myDataAdapter.SelectCommand = new BigQueryCommand(mySelectQuery, myConn);
      BigQueryCommandBuilder bigQueryCommandBuilder = new BigQueryCommandBuilder(myDataAdapter);
    
      myConn.Open();
    
      DataSet myDataSet = new DataSet();
      myDataAdapter.Fill(myDataSet, "Departments");
    
      //code to modify data in dataset here
    
      //Without the BigQueryCommandBuilder this line would fail
      myDataAdapter.Update(myDataSet, "Departments");
    
      myConn.Close();
    
      return myDataSet;
    }
    Public Function SelectBigQuerySrvRows(myDataSet As DataSet, bigQueryConnection As String, mySelectQuery As String, myTableName As String) As DataSet
      Dim myConn As New BigQueryConnection(bigQueryConnection)
      Dim myDataAdapter As New BigQueryDataAdapter()
      myDataAdapter.SelectCommand = New BigQueryCommand(mySelectQuery, myConn)
      Dim bigQueryCommandBuilder As BigQueryCommandBuilder = New BigQueryCommandBuilder(myDataAdapter)
    
      myConn.Open()
    
      Dim myDataSet As DataSet = New DataSet
      myDataAdapter.Fill(myDataSet, "Departments")
    
      ' Code to modify data in DataSet here
    
      ' Without the BigQueryCommandBuilder this line would fail.
      myDataAdapter.Update(myDataSet, "Departments")
    
      myConn.Close()
    
      SelectBigQuerySrvRows = myDataSet
    End Function
    Inheritance Hierarchy

    System.Object
       System.MarshalByRefObject
          System.ComponentModel.Component
             System.Data.Common.DbCommandBuilder
                Devart.Common.DbCommandBuilderBase
                   Devart.Common.DbCommandBuilder
                      Devart.Data.SqlShimCommandBuilder
                         Devart.Data.BigQuery.BigQueryCommandBuilder

    See Also