Skip to main content

Notifications

Announcements

No record found.

Customer Service forum

Dynamics 365 Class Library

Posted on by 25

Hi,

i'm creating a CRM class library that will call from Azure functions and other web based applications, to make the the library more robust and better performance what is the best practices we have to handle for example my case i'm using early bound classes and using singleton concept creating CRMServiceContext , is it recommended or is there a best way?

please suggest me to create in best way, approx the function has to process at least 5000 requests per day. 

private static XrmServiceContext context = null;
private static readonly object padlock = new object();
 private static IOrganizationService _orgService;

  public CRMContext(string connectionString)
        {

            lock (padlock)
            {
                if (context == null)
                {

                    if (_orgService == null)
                    {
                        _orgService = CreateProxy(connectionString);
                        if (_orgService == null)
                            throw new Exception("Error connecting to CRM");
                    }
                    context = new XrmServiceContext(_orgService);
                }
            }
        }

Calling from Azure function

using (XrmServiceContext context = CRMContext.Instance(tempconnection))
{

// to do my logic that returns complex custom class object

}

Categories:

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans