NetCoreForce.Models 6.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NetCoreForce.Models --version 6.0.0
                    
NuGet\Install-Package NetCoreForce.Models -Version 6.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetCoreForce.Models" Version="6.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetCoreForce.Models" Version="6.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NetCoreForce.Models" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetCoreForce.Models --version 6.0.0
                    
#r "nuget: NetCoreForce.Models, 6.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetCoreForce.Models@6.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetCoreForce.Models&version=6.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NetCoreForce.Models&version=6.0.0
                    
Install as a Cake Tool

NetCoreForce.Models

Strongly typed C# model classes for the standard Salesforce objects, such as Account, Contact, Opportunity and Case, for use with the NetCoreForce.Client Salesforce REST API library for .NET.

The models were generated from a standard Salesforce org using Salesforce API v67.0. They don't include any custom objects or custom fields.

Documentation: https://netcoreforce.com/

Install

dotnet add package NetCoreForce.Models

Usage

List<SfContact> contacts = await client.Query<SfContact>("SELECT Id, FirstName, LastName, Email, Account.Name FROM Contact");

SfAccount account = await client.GetObjectById<SfAccount>(SfAccount.SObjectTypeName, "001XXXXXXXXXXXXXXX");

Each class exposes its Salesforce object name through the static SObjectTypeName property, e.g. SfAccount.SObjectTypeName is "Account".

Using these models is optional, but strongly typed models are preferable in most cases.

Custom Objects and Fields

To generate models for your own org, including custom objects and custom fields, use the NetCoreForce.ModelGenerator tool. It can also generate models for a newer Salesforce API version.

If you only need to add a few custom fields, you can inherit from a model class and add the properties:

public class MyCustomAccount : SfAccount
{
    [JsonProperty(PropertyName = "myCustomField__c")]
    public string MyCustomField__c { get; set; }
}

Naming

The classes are all prefixed with "Sf", e.g. SfAccount, SfContact. This avoids naming conflicts with reserved names such as Namespace and Domain, and confusion with common .NET types such as Case and Task. It also makes the models easy to find in IntelliSense by typing "Sf". The ModelGenerator can generate the classes with plain object names, or another prefix or suffix, if preferred.

Field Metadata and Serialization

Each field is annotated with basic Salesforce metadata: the label, name, type, and whether it is nillable.

///<summary>
/// Account ID
/// <para>Name: Id</para>
/// <para>SF Type: id</para>
/// <para>Nillable: False</para>
///</summary>
[JsonProperty(PropertyName = "id")]
[Updateable(false), Createable(false)]
public string Id { get; set; }

The Updateable and Createable attributes control which properties are serialized when creating and updating records, so each request only includes the fields appropriate for that operation. For example, the Id field is assigned by Salesforce and can never be set on create or update, so it is deserialized when retrieving records but omitted from create and update requests.

Properties that can be used on both create and update omit the attributes, which default to true:

[JsonProperty(PropertyName = "name")]
public string Name { get; set; }

This is the same as:

[JsonProperty(PropertyName = "name")]
[Updateable(true), Createable(true)]
public string Name { get; set; }

Relationships

Object relationships are included in the models:

///<summary>
/// ReferenceTo: Account
/// <para>RelationshipName: Parent</para>
///</summary>
[JsonProperty(PropertyName = "parent")]
[Updateable(false), Createable(false)]
public SfAccount Parent { get; set; }

This supports query results that include related objects. For example, querying Parent.Name on Account deserializes the related account into the Parent property. To set or change a relationship, update the lookup Id field instead, e.g. ParentId.

Nullable Values

Value types such as int and decimal are generated as nullable properties (int?, decimal?), since most Salesforce fields can be null. A non-nullable property would deserialize a null field as its default value, e.g. 0, instead of null.

Null properties are not serialized by default, so setting a property to null leaves the field unchanged when updating a record. To clear a field, set it to null and include its name in the fieldsToNull parameter of UpdateRecord. See the Examples for details.

Licensed under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.1.0 56 10/7/2026
6.0.0 120 10/6/2026
5.0.0 140,483 6/22/2025
5.0.0-Beta 233 2/24/2025
4.1.0 302,843 5/24/2024
4.1.0-Beta 1,121 3/29/2024
4.0.0 117,820 6/6/2023
4.0.0-beta 657 1/24/2023
3.1.0 170,459 1/13/2022
3.0.1 49,573 5/7/2021
3.0.0 4,490 2/11/2021
3.0.0-Beta2 513 1/28/2021
2.7.0 1,110 1/4/2021
2.6.0 48,178 12/17/2019
2.5.0 23,581 11/25/2018
2.4.0 3,618 10/9/2018
2.3.0 1,186 9/18/2018
2.2.0 3,538 4/17/2018
2.1.0 1,429 3/9/2018
2.0.0 1,657 3/5/2018
Loading failed

v6.0.0 adds .NET 10 and Client Credentials login, and removes EOL .NET Core 3.1 - 7.0 targets. See the CHANGELOG for full details and breaking changes: https://github.com/anthonyreilly/NetCoreForce/blob/main/CHANGELOG.md