NetCoreForce
A Salesforce REST API client library for .NET and C#
This project is not offered, sponsored, or endorsed by Salesforce.
NetCoreForce lets .NET applications query, create, update and delete Salesforce records through the Salesforce REST API, with OAuth 2.0 login, SOQL and SOSL queries, composite requests, and strongly typed models for Salesforce objects.
Install
dotnet add package NetCoreForce.Client
dotnet add package NetCoreForce.Models
Quick Start
// Log in with the OAuth Client Credentials flow
ForceClient client = await ForceClient.FromClientCredentialsAsync(
"your-client-id", "your-client-secret", "https://your-domain.my.salesforce.com/services/oauth2/token");
// Query records
List<SfAccount> accounts = await client.Query<SfAccount>("SELECT Id, Name FROM Account LIMIT 10");
- Authentication - Client Credentials, Web Server, refresh token, and other login flows
- Examples - CRUD, queries, upserts, composite requests, search, metadata and more
- API Reference - full
ForceClientreference
Library Targets
The primary target is .NET Standard 2.0 to provide the widest possible support.
- .NET Standard 2.0 for widest possible support including .NET Framework 4.6.2+
- .NET Standard 2.1 for newer .NET Core versions
For more info on .NET Standard compatibility see the Microsoft documentation here
Full target list
- .NET Standard 2.0
- .NET Standard 2.1
- .NET 8.0
- .NET 9.0
- .NET 10.0
- .NET Framework 4.6.2
- .NET Framework 4.7.2
- .NET Framework 4.8
- .NET Framework 4.8.1
All possible frameworks are specifically targeted so that conditional compilation can be done where required.
Full tested support is for .NET 8.0 - 10.0 as tooling and tests target those. Legacy .NET Frameworks are partially tested.
NuGet Packages
- NetCoreForce.Client - the Salesforce REST API client
- NetCoreForce.Models - pre-generated models for standard Salesforce objects
- NetCoreForce.ModelGenerator - .NET CLI tool to generate models for your org, including custom objects and fields
CHANGELOG
Projects in this solution
- NetCoreForce.Client
- Main library
- NetCoreForce.Client.Tests
- Unit tests (offline/mocked)
- NetCoreForce.FunctionalTests
- Online Unit tests (Needs valid login credentials)
- NetCoreForce.ModelGenerator
- Check README for docs
- Optional custom dotnet-cli tool for code generation of custom objects/fields.
- NetCoreForce.Models
- Check README for docs
- Optional library with a set of pre-generated standard models
- SampleConsole
- A simple .NET console app to demonstrate the library.
Designed to minimize dependencies
- Newtonsoft.Json (JSON Serialization)
- System.Text.Encodings.Web (URL formatting)
- Microsoft.Bcl.AsyncInterfaces
- Only included in .NET Standard 2.0 and .NET Framework targets
- Provides await using, async disposables
(Migration from Newtonsoft.Json to System.Text.Json is planned)
Feedback and suggestions welcome.
Licensed under the MIT license.