c# - Who get Access to the Database in MVVM Pattern -


After reading many articles about this, I still do not really know how the best solution can look. / P>

Some should tell me the ViewModel and model should get access to the database telling me that only models should be accessed .

And does it also depend on the way it actually connects to my database?
If I want to use a repository then both of them can actually access it
and if I want to use EF then now only "models" are able to do database interaction?

Does any general rule do not know which database should you get access to?

You should split your application into layers

  • UI layer - Responsible for the graphic part of your app with your visual and view models.
  • Business Layer - This is your layer UI layer that contains all the logic and it acts as the gateway of your database. It includes your model and domain model.
  • Database layer - This layer is responsible for all communications in your database, generally your data is used and continues to provide generic methods for your business layer.

    You should keep a clear fragmentation between your UI and data.

    There are several differences on this setup.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -