EC.DynamicsClient 5.2.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package EC.DynamicsClient --version 5.2.4
                    
NuGet\Install-Package EC.DynamicsClient -Version 5.2.4
                    
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.2.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EC.DynamicsClient" Version="5.2.4" />
                    
Directory.Packages.props
<PackageReference Include="EC.DynamicsClient" />
                    
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 EC.DynamicsClient --version 5.2.4
                    
#r "nuget: EC.DynamicsClient, 5.2.4"
                    
#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.2.4
                    
#: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.2.4
                    
Install as a Cake Addin
#tool nuget:?package=EC.DynamicsClient&version=5.2.4
                    
Install as a Cake Tool

Introduction

This library Dynamics Client wraps calls to Dynamics 365 so you can use this to extend Dynamics 365.

Getting Started using Code Samples

namespace EC.DynamicsClient.CodeSamples;

using EC.DynamicsClient;

using Microsoft.Extensions.DependencyInjection;

using System;
using System.Threading.Tasks;

/// <summary>
/// Dynamics Client Code Samples
/// </summary>
public static class Dynamics_Client_Code_Samples
{
    /// <summary>
    /// Default Dynamics Client Setup Startup
    /// </summary>
    /// <param name="services">The service collection</param>
    /// <returns>The updated service collection</returns>
    public static IServiceCollection Default_Dynamics_Client_Setup_Startup(this IServiceCollection services) => services
        .AddDynamicsClients();

    /// <summary>
    /// Default Dynamics Client Setup Startup with Keys
    /// </summary>
    /// <param name="services">The service collection</param>
    /// <param name="authorityKeyName">The authority key name</param>
    /// <param name="clientIdKeyName">The client ID key name</param>
    /// <param name="clientSecretKeyName">The client secret key name</param>
    /// <param name="serviceEndpointKeyName">The service endpoint key name</param>
    /// <param name="scopesKeyName">The scopes key name</param>
    /// <param name="retryCountKeyName">The retry count key name</param>
    /// <returns>The updated service collection</returns>
    public static IServiceCollection Default_Dynamics_Client_Setup_Startup_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);

    /// <summary>
    /// Default Dynamics Query Client Usage
    /// </summary>
    /// <param name="dynamicsQueryClient">The dynamics query client</param>
    /// <returns>A task representing the asynchronous operation</returns>
    public static async Task Default_Dynamics_Query_Client_Usage(IDynamicsQueryClient dynamicsQueryClient)
    {
        try
        {
            var entityCollection = await dynamicsQueryClient
                .ThrowIfNull()
                .Get<Contact>(
                    Contact
                    .EntitySet
                    .Query()
                    .Where([
                        Contact.Field_fullname.Contain("Bob"),
                        Contact.Field_fullname.Starts_With("Dan"),
                        Contact.Field_ownerid_value.Equal_User_Id()
                    ])
                    .Top(10)
                    .Select([
                        Contact.Field_firstname,
                        Contact.Field_lastname,
                        Contact.Field_contactid
                    ])
                    .OrderBy([
                        Contact.Field_createdon.Order_By()
                    ])
                    .ExpandOn(
                        Contact.Nav_Accounts
                        .Expand()
                        .Select([Account.Field_accountid])
                        .Where([
                            Account.Field_ownerid_value.Equal_User_Id()
                        ])
                        .Build())
                    .ExpandOn([
                        Contact.Nav_Subscriptions
                            .Expand()
                            .Select([Subscription.Field_subscriptionid])
                            .Where([
                                Subscription.Field_ownerid_value.Equal_User_Id()
                            ])
                            .ExpandOn([
                                Subscription.Nav_Accounts
                                    .Expand()
                                    .Select([Account.Field_accountid])
                                    .Build()
                            ])
                            .Build()
                    ])
                    .Build())
                .ConfigureAwait(false);

            if (entityCollection?.Entities is not null)
            {
                foreach (var item in entityCollection.Entities)
                {

                }
            }
        }
        catch (FailedStatusCodeException exception)
        {
            var dynamics_error = await exception.Response.GetDynamicsError().ConfigureAwait(false);
            var dynamics_error_message = dynamics_error?.GetMessage();
            var dynamics_error_stacktrace = dynamics_error?.GetStackTrace();
        }
    }

    /// <summary>
    /// Default Dynamics Manager Client Usage
    /// </summary>
    /// <param name="dynamicsManagerClient">The dynamics manager client</param>
    /// <returns>A task representing the asynchronous operation</returns>
    public static async Task Default_Dynamics_Manager_Client_Usage(IDynamicsManagerClient dynamicsManagerClient)
    {
        var createResponse = await dynamicsManagerClient
            .ThrowIfNull()
            .CreateAsync(new CreateRequest<Contact>(Contact.EntitySet, new()
            {
                FirstName = "test first name",
                LastName = "test last name",
            }, headerSet: new HeaderSet([new AddPrefer([new ReturnRepresentation()])]))).ConfigureAwait(false);
        if (createResponse.IsSuccessStatusCode is false)
        {
            var dynamics_error = await createResponse.GetError().ConfigureAwait(false);
            var dynamics_error_message = dynamics_error?.GetMessage();
            var dynamics_error_stacktrace = dynamics_error?.GetStackTrace();
        }

        var created_contact = await createResponse.GetData().ConfigureAwait(false);
        var contact_id = created_contact?.ContactId;
    }
}

/// <summary>
/// Dynamics Data Models
/// </summary>
class Contact
{
    public const string EntitySet = "contacts";

    public const string Field_contactid = "contactid";
    public const string Field_firstname = "firstname";
    public const string Field_lastname = "lastname";
    public const string Field_fullname = "fullname";
    public const string Field_createdon = "createdon";
    public const string Field_ownerid_value = "fullname";

    public const string Nav_Accounts = "Accounts";
    public const string Nav_Subscriptions = "Subscriptions";

    public Guid? ContactId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}
class Account
{
    public const string EntitySet = "accounts";

    public const string Field_accountid = "accountid";
    public const string Field_ownerid_value = "_ownerid_value";

    public Guid? ContactId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}
class Subscription
{
    public const string EntitySet = "subscriptions";

    public const string Field_subscriptionid = "subscriptionid";
    public const string Field_ownerid_value = "_ownerid_value";

    public const string Nav_Accounts = "Accounts";

    public Guid? ContactId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

Contribute

To Contribute, clone repository locally then create a new branch from master/main and make any changes on that branch. When happy with changes create pull request for review.

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 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.

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 300 12/9/2024
5.6.3 119 11/26/2024
5.6.1 106 11/19/2024
5.6.0 122 11/11/2024
5.5.0 255 10/14/2024
5.4.0 257 9/20/2024
5.3.2 127 8/30/2024
5.3.1 403 5/13/2024
5.2.4 898 4/9/2024
5.2.3 141 3/24/2024
5.2.2 121 3/24/2024
5.1.3 439 3/19/2024
5.1.2 177 3/9/2024
5.1.1 158 3/7/2024
5.0.4 159 3/3/2024
4.4.1 505 11/22/2023
4.3.1 157 11/22/2023
4.2.3 332 8/16/2023
4.2.2 688 8/13/2023
4.2.1 267 7/23/2023
4.1.4 249 7/21/2023
4.1.3 233 7/20/2023
4.1.2 239 7/16/2023
4.1.1 241 7/12/2023
4.1.0 256 7/6/2023
4.0.0 221 6/26/2023
3.14.1 281 6/17/2023
3.13.1 233 5/25/2023
3.12.5 341 3/18/2023
3.12.4 323 3/14/2023
3.12.3 324 3/13/2023
3.12.2 343 3/9/2023
3.12.1 1,238 11/12/2022
3.12.0 454 11/12/2022
3.11.0 475 11/10/2022
3.10.0 535 10/22/2022
3.9.0 499 10/17/2022
3.8.0 2,447 8/16/2021
3.7.6 525 8/2/2021
3.7.5 493 8/2/2021
3.7.4 955 6/30/2021
3.7.3 497 6/30/2021
3.7.1 975 6/19/2021
3.4.1 545 5/31/2021
3.4.0 496 4/14/2021
3.3.1 545 4/1/2021
3.3.0 532 3/19/2021
3.2.2 611 2/17/2021
3.2.1 490 2/17/2021
3.2.0 481 2/14/2021
3.1.0 466 2/14/2021
3.0.1.5 513 2/11/2021
2.2.1 598 3/4/2022