I have the following code:
public AccountService(ModelStateDictionary modelStateDictionary, string dataSourceID)
{
this._modelState = modelStateDictionary;
this._accountRepository = StorageHelper.GetTable<Account>(dataSourceID);
this._productRepository = StorageHelper.GetTable<Product>(dataSourceID);
}
public AccountService(string dataSourceID)
{
this._accountRepository = StorageHelper.GetTable<Account>(dataSourceID);
this._productRepository = StorageHelper.GetTable<Product>(dataSourceID);
}
Is there some way that I can simplify the constructors so each doesn’t have to do the StorageHelper calls?
Also do I need to specify this. ?
This will first call your other constructor. You can also use
base(...to call a base constructor.thisin this case is implied.