TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sanjay Sharma
1.3k
413
27.7k
How to avoid Multiple calls to private common function
Feb 7 2018 11:17 PM
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<EmployeeModel> RetrieveAllContacts()
{
CreateCrmServiceInstance();
// do something using _service
}
public List<ContactModel> UpdateContactStatus()
{
CreateCrmServiceInstance();
// do something using _service
}
Reply
Answers (
2
)
Email verifier email address exists or not
Insert into Select Query Question