I have class that has many public method which perfrom differnet service operations.
Inorder to do service operation it need to create service Instance.
How do I avoid calling private method from each function?
code snippet.
public class EmployeeModel
{
private IOrganizationService _service = CRMConnect.CrmService();
private void CreateCrmServiceInstance()
{
if (_service == null){
_service = CRMConnect.CrmService();
}
}
public List RetrieveAllContacts()
{
CreateCrmServiceInstance();
// do something using _service
}
public List UpdateContactStatus()
{
CreateCrmServiceInstance();
// do something using _service
}

Amit GuptaRank #190 · 12.8K reputationPosted Feb 7, 2018, 7:04 PM EST
Sanjay SharmaRank #3,576 · 407 reputationPosted Feb 11, 2018, 11:59 PM EST