I am creating a .Net Core API with multiple layers
Customer.API
Customer.Business
CustomerService
Customer.Libs
This API has to call 2 Database Systems at this moment (same updates should go to both the systems) and in near future one of the Systems will be decommissioned.
- DynamoDB
- SQL Server
I created the repository layer like below and would like to know if this is the correct approach.
Create an abstraction layer and have classes like this in Customer.Libs
MultiDbBaseRepository.cs
SQlServerBaseRepository.cs
MultiDbBaseRepository => This class will call both repository classes SQLDatabaseRespository and DynamoDbRepository SQlServerBaseRepository => This class will call SQLDatabaseRespository.
Add Dependency to MultiDbRepository in Startup.cs at this moment or drive this instantiation based on some settings, to avoid code deployments in future.
AddScoped<ICustomerBaseRespository, MultiDbBaseRepository >
So, Service layer uses ICustomerBaseRespository and at this moment application will call MultiDbBaseRepository and the changes get updated to both SQL and Dynamodb and if the Startup is changed in future then the application will call the necessary Database.
Can you please let me know if I am violating design pattern?
Aucun commentaire:
Enregistrer un commentaire