web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Customer Service forum

Dynamics 365 Class Library

(0) ShareShare
ReportReport
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:
I have the same question (0)

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

News and Announcements

Season of Giving Solutions is Here!

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 > Customer Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans