❔ blazor wasm 6 databases
Hello guys I have a project
in blazor and each dbcontext database in a different class library (repository pattern) I have to make simple queries based on variable which indicates what database to choose.
My plan is just simply put in each class library the same repository with interface and almost same implementation of the methods.
Then in my service get all repositories from 6db I can distinguish them by proper syntax in using and do switch statement...
I guess this is not optimal as I'm repeating myself should I maybe make abstract class? Or write generic method which gonna take different database and query them?
5 Replies
Why tf would you be using 6 databases...?
I'd start thinking about the solution here lol
Other than that, assuming the databases have the same structure (but why tf would you be using multiple if that's the case) just use multiple DbContexts and inject those into your repositories
Each db is slightly different but they all have specific dbsets that I need ...
Is it my solution good?
Each db has repository with same interface and then in my service I will get them all by DI and call the one I need
We have 6 because they are for different subsidiaries
At a glance, it does seem like the least-bad solution, yeah
Hey at least someone who made it followed some pattern instead of putting 1500lines of code in one method 💪
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.