製品をチェック

無償トライアル:

無償トライアルへ

製品の情報と無償トライアルへ:

SingleStore ADO.NET Provider

SingleStore データに連携する.NET アプリケーションを素早く、簡単に開発できる便利なドライバー。

データ連携でお困りですか?

お問い合わせ

Provide OData Services of SingleStore Data from a WCF Application


This article shows how to publish an OData feed of SingleStore data by creating a WCF Service Application.


加藤龍彦
ウェブデベロッパー

The CData ADO.NET Provider for SingleStore enables you to use the Windows Communication Foundation (WCF) framework to rapidly develop service-oriented applications that provide SingleStore data to OData consumers. This article shows how to create an entity data model to provide the underlying connectivity to the SingleStore data, as well as how to create a WCF Data Service to expose the OData service. You can then consume the feed with any OData client, for example, Power Pivot or an application that uses the CData ADO.NET Provider for OData.

Create the OData Service

Follow the steps below to create a WCF service application that will provide connectivity to SingleStore data via OData.

  1. Open Visual Studio and create a new project. Select the WCF Service Application template.
  2. Delete the autogenerated IService.cs and Service1.svc.
  3. Click Project -> Add New Item -> ADO.NET Entity Data Model.
  4. In the Entity Data Model wizard that is displayed, select the 'EF Designer from Database' option.
  5. In the resulting Choose Your Connection dialog, click New Connection.
  6. In the Connection properties dialog, select the CData SingleStore Data Source and enter the necessary credentials. A typical connection string is below:

    User=myUser;Password=myPassword;Database=NorthWind;Server=myServer;Port=3306;

    データに接続するには、次の接続プロパティが必要です。

    • Server:SingleStore データベースをホスティングしているサーバーのホスト名またはIP アドレス。
    • Port:SingleStore データベースをホスティングしているサーバーのポート。

    また、オプションで以下を設定することもできます。

    • SingleStore:SingleStore Server に接続する場合のデフォルトデータベース。設定されていない場合、すべてのデータベースのテーブルが返されます。

    標準認証

    標準認証で認証するには、次を設定します。

    • User:SingleStore サーバーに認証する際に使われるユーザー。
    • Password:SingleStore サーバーに認証する際に使われるパスワード。

    統合セキュリティを使用した接続

    標準のユーザー名とパスワードを提供する代わりに、Windows 認証を介して信頼されたされたユーザーをサーバーに認証できます。

    SSL 認証

    SSL 認証を活用してセキュアなセッションを介してSingleStore データに接続できます。次の接続プロパティを設定し、データに接続します。

    • SSLClientCert:クライアント証明書のための証明書ストア名に設定。クライアントとサーバーの両方のマシンでトラストストアとキーストアが保持される2-way SSL の場合に使用されます。
    • SSLClientCertPassword:クライアント証明書ストアがパスワードで保護されている場合、この値をストアのパスワードに設定します。
    • SSLClientCertSubject:TLS/SSL クライアント証明書のサブジェクト。ストア内の証明書を検索するために使用されます。
    • SSLClientCertType:クライアントストアの証明書タイプ。
    • SSLServerCert:サーバーが受け入れ可能な証明書。

    SSH 認証

    SSH を使用して、セキュアにリモートマシンにログインできます。SingleStore データにSSH 経由でアクセスするには、次の接続プロパティを設定します。

    • SSHClientCert:クライアント証明書のための証明書ストア名に設定。
    • SSHClientCertPassword:クライアント証明書ストアがパスワードで保護されている場合、この値をストアのパスワードに設定します。
    • SSHClientCertSubject:TLS/SSL クライアント証明書のサブジェクト。ストア内の証明書を検索するために使用されます。
    • SSHClientCertType:クライアントストアの証明書タイプ。
    • SSHPassword:SSH サーバーに認証するためのパスワード。
    • SSHPort:SSH 操作に使用するポート。
    • SSHServer:認証しようとしているSSH 認証サーバー。
    • SSHServerFingerPrint:接続先のホストの検証に使用するSSH サーバーのフィンガープリント。
    • SSHUser:SSH サーバーに認証するためのユーザー名。

    See the help documentation for guides to connecting in Visual Studio.

    Required connection properties, specified in the Add Connection dialog. (Salesforce is shown.)
  7. Select SingleStore tables and views that you want OData clients to access. Available tables in the Entity Data Model Wizard. (Salesforce is shown.)
  8. Click Project -> Add New Item -> WCF Data Service.
  9. Specify the data source class and configure access to the new WCF Data Service. In the example below, the Access Rule for the entities is set to All. This means that any user will be able to read and modify data.

    using System; using System.Collections.Generic; using System.Data.Services; using System.Data.Services.Common; using System.Linq; using System.ServiceModel.Web; using System.Web; namespace SingleStoreService{ public class SingleStoreDataService : DataService { public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3; } } }
  10. Run the project. Applications that support OData can now access the Salesforce data and reflect any changes. You can access the feed in your browser. The feed will resemble the following:
  11. The raw OData feed. (Salesforce is shown.)

Consume the OData Service from Power Pivot

You can now use the service from any OData client; for example, Excel Power Pivot.

  1. Open Excel and click on the Power Pivot Window button.
  2. A new pop-up will appear. Select the option From Data Feeds.
  3. In the resulting Table Import Wizard, enter the OData URL. For example, http://localhost:12449/SingleStoreDataService.svc/. The OData URL for SingleStore.
  4. After connecting to the OData service, click the Next button at the bottom of the window.
  5. A table listing of the available tables will appear in the next window of the wizard. Select which tables you want to import and click Finish. Available tables in the Table Import Wizard. (Salesforce is shown.)
  6. Click Close to import the data in Power Pivot. The table loaded in Power Pivot. (Salesforce is shown.)