posts - 88 , comments - 3 , trackbacks - 0

LINQ to QuickBooks 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 Data Providers for ADO.NET. This example uses LINQ to access information from the QuickBooks Data Provider.

This article demonstrates how to use LINQ to access QuickBooks through the QuickBooks ADO.NET Data Provider. 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.

  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 to generate from database and click next.
  3. Add a new Data Connection, and change your data source type to "CData QuickBooks Data Source".
  4. Enter your data source connection information.
  5. Required connection properties for the data source. 
  6. If saving your entity connection to App.Config, set an entity name. In this example we are setting APIEntities as our entity connection in App.Config.
  7. Enter a model name and select any tables or views you would like to include in the model.
The available tables in the underlying data source. 

Using the entity you created, you can now perform select, update, delete, and insert commands. For example:

APIEntities context = new APIEntities();
var accountsQuery = from invoice in context.Leads
orderby accounts.AnnualRevenue
select accounts;
foreach (var result in accountsQuery) {
Console.WriteLine("csharp {1} ", result.Id, result.Company);

Print | posted on Monday, June 15, 2015 2:16 AM | Filed Under [ .net quickbooks cdata LINQ .Net Framework ]

Powered by: