We are proud to share our inclusion in the 2024 Gartner Magic Quadrant for Data Integration Tools. We believe this recognition reflects the differentiated business outcomes CData delivers to our customers.
Get the Report →Create OData Services with the Salesforce Data Provider
The CData ADO.NET Provider for Salesforce enables you to use the Windows Communication Foundation (WCF) framework to rapidly develop service-oriented applications that provide Salesforce data to OData consumers. This article shows how to create an entity data model to provide the underlying connectivity to Salesforce, 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 Salesforce via OData.
- Open Visual Studio and create a new project. Select the WCF Service Application template.
- Delete the autogenerated IService.cs and Service1.svc.
- Click Project -> Add New Item -> ADO.NET Entity Data Model.
- In the Entity Data Model wizard that is displayed, select the 'EF Designer from Database' option.
- In the resulting Choose Your Connection dialog, click New Connection.
In the Connection properties dialog, select the CData Salesforce Data Source and enter the necessary credentials. Typical connection properties are User, Password, and Access Token. OAuth is also supported.
See the "Getting Started" chapter in the help documentation for guides to connect from Visual Studio.
- Select Salesforce tables and views that you want OData clients to access.
- Click Project -> Add New Item -> WCF Data Service.
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 SalesforceService{ public class SalesforceDataService : DataService<SalesforceEntities> { public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3; } } }
-
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:
Consume the OData Service in Power Pivot
Follow the steps below to use the service from any OData client; for example, Excel Power Pivot.
- In Excel, open Power Pivot by clicking the Power Pivot Window icon on the Power Pivot tab.
- Click Get External Data from Other Data Sources.
- In the resulting dialog, select the "Other Feeds"option.
- In the resulting Table Import Wizard, enter the OData URL. For example, http://localhost:12449/SalesforceDataService.svc/.
- Select which tables you want to import.
- You can now use the Salesforce data in Power Pivot.
Consume the OData Service with the CData OData Provider
To help you get started using the ADO.NET Data Providers for Salesforce and OData, you can download the fully functional sample project. You need the ADO.NET Provider for Salesforce to host the OData service, and the ADO.NET Provider for OData to consume the OData service. To get started, download the Salesforce Provider free trial and OData Provider free trial.
Note: Before running the demos you will need to reconfigure the connection strings with your specific Salesforce.com credentials.
CodeProject