Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

DevExpress/BigQueryProvider

Repository files navigation

⛔ DEPRECATED. The DevExpress BigQueryProvider driver is no longer maintained and supported. Use Google's official ODBC driver to obtain BigQuery data in your .NET apps. Refer to the following breaking change for more information: https://supportcenter.devexpress.com/ticket/details/t1082645.


BigQueryProvider

What is BigQueryProvider?

BigQueryProvider is an open-source ADO.NET data provider that you can use to connect your .NET application to Google BigQuery.

This data provider incorporates Google.Apis.Bigquery.v2 API and implements all client-side functionality required to interact with BigQuery datasets. It uses mechanisms common for all ADO.NET data providers and allows you to utilize the same data binding methods that you use when connecting to data via standard ADO.NET data providers

Requirements

BigQueryProvider is compatible with .NET Standard 2.0 or higher. The Google.Apis.Bigquery.v2 library and all its dependencies are required to build BigQueryProvider from source. This library should also be deployed with the final application.

Installation

BigQueryProvider is available as a NuGet package. Follow the steps below to download and install it into your Visual Studio project:

  1. Right-click your project in the Visual Studio Solution Explorer and select Manage NuGet Packages in the context menu.
  2. In NuGet Package Manager, search for the DevExpress.DataAccess.BigQuery package. Select the package and click Install.
  3. In the confirmation window, click OK to proceed.
  4. In the License Acceptance dialog, click I Accept to start the installation.

Alternatively, execute the following command in the NuGet Package Manager Console:

Install-Package DevExpress.DataAccess.BigQuery

Build from source

To build the BigQueryProvider library from source, open its solution in Visual Studio, set the solution configuration to Release and click Build->Build Solution. On the first build, NuGet will prompt you to download and install library dependencies.

BigQueryProvider source code comes with a set of NUnit tests. You can run them to ensure that the current library version operates correctly. We recommended that you run the tests to validate any changes you have made to the library source code.

To run these tests, you first need to setup the required testing infrastructure:

  1. Add a connection string for your BigQuery dataset to the application’s configuration file. We recommend that you use a separate dataset for testing purposes.
  2. Use your test runner of choice to run the CreateDBTables explicit test available in the TestingInfrastructureHelper class. This test will populate the dataset with tables required to correctly run the rest of unit tests.

Connection String Parameters

BigQuery connection strings require the following mandatory connection string parameters.

  • ProjectID – the name of the Google Cloud Platform project that hosts the dataset.
  • DatasetID – the dataset name.

Additionally, a connection string should contain parameters that specify authentication settings. BigQuery supports two authentication methods: OAuth 2.0 or service account credentials. Depending on the authentication method you use, you need to specify one of the following two sets of connection string parameters.

OAuth
  • OAuthClientID – The client ID provided by BigQuery.
  • OAuthClientSecret – The secret character sequence generated by BigQuery when creating a new client.
  • OAuthRefreshToken – The token used to start a new authorization session and receive a new Access Token when an old one expires.
Service Account
  • ServiceAccountEmail – specifies the email address associated with a Google Cloud Platform service account.
  • PrivateKeyFileName – the path to the key file.

How to Use BigQueryProvider

A code sample below demonstrates how to use BigQueryProvider to connect your application to a BigQuery dataset.

using(var connection = new BigQueryConnection(@"ProjectID=myProject;
                                                DataSetId=myDataSet;
                                                OAuthClientId=myClientId;
                                                OAuthClientSecret=mySecret;
                                                OAuthRefreshToken=myRefreshToken"))
                                                 {
    connection.Open();
    using(var command = new BigQueryCommand()) {
        command.Connection = connection;

        // Retrieve all rows
        command.CommandText = @"SELECT myTable.myField 
                                FROM myDataSet.myTable myTable";
        using(var reader = command.ExecuteReader()) {
            while(reader.Read()) {
                Console.WriteLine(reader.GetString(0));
            }
        }
    }
}

This example first creates a new BigQueryConnection and specifies the connection string. The following part uses the connection to execute a SELECT query against a BigQuery dataset. Finally, a BigQueryDataReader is used to iterate through dataset rows.

About

The DevExpress BigQueryProvider driver is no longer maintained and supported. Use Google's official ODBC driver to obtain BigQuery data in your .NET apps.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages