LinqToSalesforce


LinqToSalesforce

Documentation

NuGet.org

The LinqToSalesforce library can be installed from NuGet:
PM> Install-Package LinqToSalesforce

MyGet.org

The LinqToSalesforce library can be installed from MyGet:
PM> Install-Package LinqToSalesforce

It will be pushed on NuGet.org after more tests and some missing features implementations.

Example

This example demonstrates how to use LINQ to SOQL. In this example, we search 10 accounts where name starts with "Company" and industry is "Biotechnology".

Then we can iterate their contacts and cases using lazy loading.

This Linq provider is written in FSharp but is originally made to be used in CSharp

In csharp

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 

var impersonationParam = new Rest.OAuth.ImpersonationParam(clientId, clientId, securityToken, username, password);
var context = new SalesforceDataContext("eu11", impersonationParam);

var accounts = (from a in context.Accounts
                where !a.Name.StartsWith("Company")
                    && a.Industry == PickAccountIndustry.Biotechnology
                select a).Take(10);
foreach (var account in accounts)
{
    WriteLine($"Account {account.Name} Industry: {account.Industry}");
    var contacts = account.Contacts;
    foreach (var contact in contacts)
    {
        WriteLine($"contact: {contact.Name} - {contact.Phone} - {contact.LeadSource}");

        var cases = contact.Cases;
        foreach (var @case in cases)
        {
            WriteLine($"case: {@case.Id}");
        }
    }
}

Solutions will be proposed next.

For FSHARP developpers

Using a type provider could be really useful to visualize your salesforce data with Atom and FSlab.

typeprovider

Futur developments

For MONO users

Salesforce deactivate old SSL protocol versions.

So we need to use something difficult to use with MONO:

1: 

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding a new public API, please also consider adding samples that can be turned into a documentation. You might also want to read the library design notes to understand how it works.

The library is available under Public Domain license, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.

Fork me on GitHub