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
}