Ready to get started?

Learn more about the CData ADO.NET Provider for Google Data Catalog or download a free trial:

Download Now

LINQ to Google Data Catalog Data

LINQ provides general-purpose query facilities in .NET Framework 3.0 and above and provides one easy way to programmatically access data through from CData ADO.NET Data Providers. This example uses LINQ to access information from the Google Data Catalog Data Provider.

This article demonstrates how to use LINQ to access Google Data Catalog tables through the CData ADO.NET Data Provider for Google Data Catalog. To do this you will LINQ to Entity Framework, which is used to generate the connection and can be used with any CData ADO.NET Data Providers to access data via LINQ.

See the help documentation for a guide to setting up an EF 6 project to use the provider.

  1. In a new project in Visual Studio, right-click on the project and choose to add a new item. Add an ADO.NET Entity Data Model.
  2. Choose EF Designer from Database and click Next.
  3. Add a new Data Connection, and change your data source type to "CData Google Data Catalog Data Source".
  4. Enter your data source connection information.

    Google Data Catalog uses the OAuth authentication standard. Authorize access to Google APIs on behalf on individual users or on behalf of users in a domain.

    Before connecting, specify the following to identify the organization and project you would like to connect to:

    • OrganizationId: The ID associated with the Google Cloud Platform organization resource you would like to connect to. Find this by navigating to the cloud console.

      Click the project selection drop-down, and select your organization from the list. Then, click More -> Settings. The organization ID is displayed on this page.

    • ProjectId: The ID associated with the Google Cloud Platform project resource you would like to connect to.

      Find this by navigating to the cloud console dashboard and selecting your project from the Select from drop-down. The project ID will be present in the Project info card.

    When you connect, the OAuth endpoint opens in your default browser. Log in and grant permissions to the application to completes the OAuth process. For more information, refer to the OAuth section in the Help documentation.

    Below is a typical connection string:

    ProjectId=YourProjectId;InitiateOAuth=GETANDREFRESH
  5. If saving your entity connection to App.Config, set an entity name. In this example we are setting GoogleDataCatalogEntities as our entity connection in App.Config.
  6. Enter a model name and select any tables or views you would like to include in the model.

Using the entity you created, you can now perform select commands. For example:

GoogleDataCatalogEntities context = new GoogleDataCatalogEntities(); var schemasQuery = from schemas in context.Schemas select schemas; foreach (var result in schemasQuery) { Console.WriteLine("{0} {1} ", result.Id, result.Type); }

See "LINQ and Entity Framework" chapter in the help documentation for example queries of the supported LINQ.