NetCoreForce.Models
6.1.0
dotnet add package NetCoreForce.Models --version 6.1.0
NuGet\Install-Package NetCoreForce.Models -Version 6.1.0
<PackageReference Include="NetCoreForce.Models" Version="6.1.0" />
<PackageVersion Include="NetCoreForce.Models" Version="6.1.0" />
<PackageReference Include="NetCoreForce.Models" />
paket add NetCoreForce.Models --version 6.1.0
#r "nuget: NetCoreForce.Models, 6.1.0"
#:package NetCoreForce.Models@6.1.0
#addin nuget:?package=NetCoreForce.Models&version=6.1.0
#tool nuget:?package=NetCoreForce.Models&version=6.1.0
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.
Links
Licensed under the MIT license.
| Product | Versions 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. |
-
.NETFramework 4.6.2
- NetCoreForce.Client (>= 6.1.0)
-
.NETFramework 4.7.2
- NetCoreForce.Client (>= 6.1.0)
-
.NETFramework 4.8
- NetCoreForce.Client (>= 6.1.0)
-
.NETFramework 4.8.1
- NetCoreForce.Client (>= 6.1.0)
-
.NETStandard 2.0
- NetCoreForce.Client (>= 6.1.0)
-
.NETStandard 2.1
- NetCoreForce.Client (>= 6.1.0)
-
net10.0
- NetCoreForce.Client (>= 6.1.0)
-
net8.0
- NetCoreForce.Client (>= 6.1.0)
-
net9.0
- NetCoreForce.Client (>= 6.1.0)
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 | 0 | 10/7/2026 |
| 6.0.0 | 48 | 10/6/2026 |
| 5.0.0 | 139,573 | 6/22/2025 |
| 5.0.0-Beta | 231 | 2/24/2025 |
| 4.1.0 | 302,426 | 5/24/2024 |
| 4.1.0-Beta | 1,119 | 3/29/2024 |
| 4.0.0 | 117,790 | 6/6/2023 |
| 4.0.0-beta | 654 | 1/24/2023 |
| 3.1.0 | 170,405 | 1/13/2022 |
| 3.0.1 | 49,556 | 5/7/2021 |
| 3.0.0 | 4,489 | 2/11/2021 |
| 3.0.0-Beta2 | 510 | 1/28/2021 |
| 2.7.0 | 1,108 | 1/4/2021 |
| 2.6.0 | 48,169 | 12/17/2019 |
| 2.5.0 | 23,580 | 11/25/2018 |
| 2.4.0 | 3,617 | 10/9/2018 |
| 2.3.0 | 1,185 | 9/18/2018 |
| 2.2.0 | 3,537 | 4/17/2018 |
| 2.1.0 | 1,428 | 3/9/2018 |
| 2.0.0 | 1,655 | 3/5/2018 |
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