Ready to get started?

Learn more about the CData ADO.NET Provider for Epicor ERP or download a free trial:

Download Now

LINQ to Epicor ERP 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 Epicor ERP Data Provider.

This article demonstrates how to use LINQ to access Epicor ERP tables through the CData ADO.NET Data Provider for Epicor ERP. 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 Epicor ERP Data Source".
  4. Enter your data source connection information.

    To successfully connect to your ERP instance, you must specify the following connection properties:

    • Url:the URL of the server hosting your ERP instance. For example, https://myserver.EpicorSaaS.com
    • ERPInstance: the name of your ERP instance.
    • User: the username of your account.
    • Password: the password of your account.
    • Service: the service you want to retrieve data from. For example, BaqSvc.

    In addition, you may also set the optional connection properties:

    • ApiKey: An optional key that may be required for connection to some services depending on your account configuration.
    • ApiVersion: Defaults to v1. May be set to v2 to use the newer Epicor API.
    • Company: Required if you set the ApiVersion to v2.

    Below is a typical connection string:

    ervice=Erp.BO.CustomerSvc;ERPInstance=MyInstance;URL=https://myaccount.epicorsaas.com;User=username;Password=password;InitiateOAuth=GETANDREFRESH
  5. If saving your entity connection to App.Config, set an entity name. In this example we are setting EpicorERPEntities 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 , update, delete, and insert commands. For example:

EpicorERPEntities context = new EpicorERPEntities(); var customersQuery = from customers in context.Customers select customers; foreach (var result in customersQuery) { Console.WriteLine("{0} {1} ", result.Id, result.CustNum); }

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