--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/VkBCAGzuaPE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.
Having any dependency in your model is a recipe for disaster.
Having a session in a view model is ok.
Having any dependency in your model is a recipe for disaster.
--
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
Mvvm often has services injected into the viewmodel!
This is just purist nonsense.
You don't do this in your model in most DDD style systems because of serialization concerns and to maintain persistence ignorance. If you are doing this in your model then you are likely following the Active Record pattern.
Give me one valid reason a viewmodel can't have a service injected into it. There is no issue with a view model hydrating itself.
Assume you have some concepts in your code called Models, Views, View Models, and Controllers. If the View Models hydrate themselves from persistence, what is happening in the Controllers? What role do the Models have?
Since getting a View Model from a, *cough*, container would be awkward, it appears that the Controller takes on the role of a low grade DI component to hand out sessions, et al. [fwiw, this is the piece the OP is missing - hand the session to the model].If you are going to have the View Models construct themselves, why bother calling them View Models? That seems to muddy the water.I have, myself, written code in which the view model hydrates itself. It seemed like it was working at first. I stopped doing it because it became painful.
What we end up with is a situation in which every request is a new adventure and persistence calls are happening in several different places. Reasoning about behavior becomes hard. Optimization becomes really hard.
It leads to pain in asp.net mvc.
I can't comment on how it would work in an environment that _wants_ to do mvvm.
Asp.net mvc doesn't want to do mvvm.
Fwiw, I've listened to many a rails dev bemoan the perils of active record.
There are probably lots of low value situations in every system that is best disposed of with active record / crud scaffolding. I've used such for things like admin settings.