c# - Does my View Model have my Model and my Repository instance? -


hopefully being clear here. have viewmodel called a. have model called m. have repository model m , db stuff maps called rm.

would viewmodel, a, have property of model m , 1 repository rm.

i use calling various methods on rm , bind m pass methods in rm save().

make sense? "normal" or close?

you describing typical situation, depending on preferences. if view model wishes work entities, via repository inject dependency using constructor injection, , view model work against abstraction rather specific implementation of repository.

if wished access repository @ later point after construction, assign repository private field or property example.

in terms of model, have property exposes view didn't need duplicate properties of model on view model. however, depend on whether happy view having direct access model violation of lod (law of demeter) in order not violate dry (don't repeat yourself) principle.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -