I am creating one repository and I have to deal with two data providers(IFileDataAccess, IDbDataAccess) to build my model object(MyModel).
I have written below code, but I feel it's not correct, it's important to have MyModel class with all written properties as they all be used together.
Please suggest a good way to achieve this.
Thanks!
class MyModel
{
public Schedule Schedule { get; set; }
public Rates Rates { get; set; }
public Balance Balance { get; set; }
}
class MyRepository
{
private IFileDataAccess _fileDataAccess;
private IDbDataAccess _dbDataAccess;
public MyClass (IFileDataAccess fileDataAccess, IDbDataAccess dbDataAccess)
{
_fileDataAccess= fileDataAccess;
_dbDataAccess=dbDataAccess;
}
public MyModel GetMyModel()
{
return new MyModel(){Schedule=_dbDataAccess.GetSchedule(),Rates=_fileDataAccess.GetRates(), Balance=_fileDataAccess.GetBalance()};
}
}
Aucun commentaire:
Enregistrer un commentaire