EC.DynamicsClient
5.7.0
dotnet add package EC.DynamicsClient --version 5.7.0
NuGet\Install-Package EC.DynamicsClient -Version 5.7.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="EC.DynamicsClient" Version="5.7.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EC.DynamicsClient" Version="5.7.0" />
<PackageReference Include="EC.DynamicsClient" />
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 EC.DynamicsClient --version 5.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EC.DynamicsClient, 5.7.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 EC.DynamicsClient@5.7.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=EC.DynamicsClient&version=5.7.0
#tool nuget:?package=EC.DynamicsClient&version=5.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Introduction
This library Dynamics Client wraps calls to Dynamics 365 so you can use this to extend Dynamics 365.
Getting Started
Code Samples
Startup
namespace EC.DynamicsClient.CodeSamples;
using EC.DynamicsClient;
using Microsoft.Extensions.DependencyInjection;
public static class Startup_Code_Samples
{
public static IServiceCollection Default(this IServiceCollection services) => services
.AddDynamicsClients();
public static IServiceCollection With_Keys(
this IServiceCollection services,
string authorityKeyName, string clientIdKeyName, string clientSecretKeyName,
string serviceEndpointKeyName, string scopesKeyName, string retryCountKeyName) => services
.AddDynamicsClients(
authorityKeyName,
clientIdKeyName,
clientSecretKeyName,
serviceEndpointKeyName,
scopesKeyName,
retryCountKeyName);
}
Then for configuration here is the default setup in JSON format, you can have the configuration hydrate from any source being host environment variables or others as long as you follow the same structure. For
Scopes
you can use{dynamics_base_adress}/.default
and forDynamicsServiceEndpoint
you can use{dynamics_base_adress}/api/data/v9.2/
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "...",
"ClientId": "...",
"ClientSecret": "...",
"Scopes": "..."
},
"DynamicsServiceEndpoint": "..."
}
Query Client Usage
namespace EC.DynamicsClient.CodeSamples;
using EC.DynamicsClient;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
static class Query_Client_Usage_Code_Samples
{
public static async Task<IResult> Query_Client_Usage(
IDynamicsQueryClient queryClient,
ILogger log,
Guid user_id)
{
var result = await queryClient.Get_Safe<Contact>(
ContactField
.EntitySetName
.Query()
.Where([ // sample filter records
ContactField.FullName.Not_Equal_Null(),
ContactField.FullName.Contain("Bob"),
ContactField.FullName.Starts_With("Dan"),
ContactField.OwnerId.Not_Equal_Null(),
ContactField.OwnerId.Equal_User_Id(),
ContactField.CreatedBy.Not_Equal(user_id)
])
.Top(10)
.Select([ // sample select fields
ContactField.FirstName,
ContactField.LastName,
ContactField.ContactId,
ContactField.CreatedBy.ToLookup(),
])
.OrderBy([ // sample order by expressions
ContactField.CreatedBy.Order_By()
])
.ExpandOn( // sample expand on expressions
ContactField.ec_Account
.Expand()
.Select([AccountField.AccountId])
.Where([
AccountField.OwnerId.Equal_User_Id()
])
.Build())
.Where([ // sample lambda expressions
Lambda.All(ContactOneToMany.account_primary_contact, [
Lambda.StartsWith(AccountField.Name, "S"),
Lambda.EndsWith(AccountField.Name, "h"),
Lambda.Contains(AccountField.Name, "Smith"),
Lambda.Equals(AccountField.StatusCode, account_statuscode.Active),
new EqualsLambdaExpression("null", "null")
]),
])
.Build()).ConfigureAwait(false);
return result.Match(
invalid =>
{
log.LogWarning("The query that was provided is invalid.");
return Results.Problem(
title: "The query that was provided is invalid.",
statusCode: StatusCodes.Status400BadRequest
);
},
contacts =>
{
log.LogInformation("Contacts found and returned.");
return Results.Ok(contacts.Entities);
},
not_found =>
{
log.LogWarning("The query that was provided did not return any results.");
return Results.NotFound();
},
failed =>
{
log.LogError("The query that was provided resulted in a failed status response.");
return Results.Problem(
title: "The query that was provided resulted in a failed status response.",
detail: failed.Error?.GetMessage(),
statusCode: StatusCodes.Status500InternalServerError,
extensions: [
new ("StackTrace", failed.Error?.GetStackTrace())
]
);
});
}
}
Manager Client Usage
namespace EC.DynamicsClient.CodeSamples;
using EC.DynamicsClient;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
static class Manager_Client_Usage_Code_Samples
{
public static async Task<IResult> Upsert_Contact_from_API_or_Web(
this IDynamicsManagerClient managerClient,
ILogger log,
AlternateKey[] keys,
Contact contact)
{
var result = await managerClient.Request(
ContactField.EntitySetName.Upsert(keys, contact)
).ConfigureAwait(false);
return result.Match(
success =>
{
log.LogInformation("The upsert request provided completed successfully.");
return Results.Ok();
},
contact =>
{
log.LogInformation("The upsert request provided completed successfully with the updated contact.");
return Results.Ok(contact);
},
invalid =>
{
log.LogWarning("The upsert request that was provided is invalid.");
return Results.Problem(
title: "The upsert request that was provided is invalid.",
statusCode: StatusCodes.Status400BadRequest
);
},
failed =>
{
log.LogError("The upsert request that was provided resulted in a failed status response.");
return Results.Problem(
title: "The upsert request that was provided resulted in a failed status response.",
detail: failed.Error?.GetMessage(),
statusCode: StatusCodes.Status500InternalServerError,
extensions: [
new ("StackTrace", failed.Error?.GetStackTrace())
]
);
});
}
}
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 was computed. 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 was computed. 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 was computed. 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | 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.
-
.NETStandard 2.1
- EC.Common (>= 2024.9.28.1)
- Microsoft.AspNet.WebApi.Client (>= 6.0.0)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 8.0.0)
- Microsoft.Extensions.Configuration.Json (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Http.Polly (>= 8.0.10)
- Microsoft.Extensions.Logging.Console (>= 8.0.1)
- Microsoft.Identity.Client (>= 4.65.0)
- System.Net.Http.Json (>= 8.0.1)
- System.Text.Json (>= 8.0.5)
- System.Threading.Channels (>= 8.0.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 |
---|---|---|
5.7.0 | 289 | 12/9/2024 |
5.6.3 | 118 | 11/26/2024 |
5.6.1 | 105 | 11/19/2024 |
5.6.0 | 121 | 11/11/2024 |
5.5.0 | 250 | 10/14/2024 |
5.4.0 | 239 | 9/20/2024 |
5.3.2 | 126 | 8/30/2024 |
5.3.1 | 402 | 5/13/2024 |
5.2.4 | 897 | 4/9/2024 |
5.2.3 | 140 | 3/24/2024 |
5.2.2 | 120 | 3/24/2024 |
5.1.3 | 438 | 3/19/2024 |
5.1.2 | 176 | 3/9/2024 |
5.1.1 | 157 | 3/7/2024 |
5.0.4 | 158 | 3/3/2024 |
4.4.1 | 504 | 11/22/2023 |
4.3.1 | 156 | 11/22/2023 |
4.2.3 | 331 | 8/16/2023 |
4.2.2 | 687 | 8/13/2023 |
4.2.1 | 266 | 7/23/2023 |
4.1.4 | 248 | 7/21/2023 |
4.1.3 | 232 | 7/20/2023 |
4.1.2 | 238 | 7/16/2023 |
4.1.1 | 240 | 7/12/2023 |
4.1.0 | 254 | 7/6/2023 |
4.0.0 | 220 | 6/26/2023 |
3.14.1 | 280 | 6/17/2023 |
3.13.1 | 232 | 5/25/2023 |
3.12.5 | 340 | 3/18/2023 |
3.12.4 | 322 | 3/14/2023 |
3.12.3 | 323 | 3/13/2023 |
3.12.2 | 342 | 3/9/2023 |
3.12.1 | 1,237 | 11/12/2022 |
3.12.0 | 453 | 11/12/2022 |
3.11.0 | 474 | 11/10/2022 |
3.10.0 | 534 | 10/22/2022 |
3.9.0 | 498 | 10/17/2022 |
3.8.0 | 2,443 | 8/16/2021 |
3.7.6 | 524 | 8/2/2021 |
3.7.5 | 492 | 8/2/2021 |
3.7.4 | 954 | 6/30/2021 |
3.7.3 | 496 | 6/30/2021 |
3.7.1 | 974 | 6/19/2021 |
3.4.1 | 544 | 5/31/2021 |
3.4.0 | 495 | 4/14/2021 |
3.3.1 | 544 | 4/1/2021 |
3.3.0 | 531 | 3/19/2021 |
3.2.2 | 610 | 2/17/2021 |
3.2.1 | 489 | 2/17/2021 |
3.2.0 | 480 | 2/14/2021 |
3.1.0 | 465 | 2/14/2021 |
3.0.1.5 | 512 | 2/11/2021 |
2.2.1 | 597 | 3/4/2022 |