I think I'm missing something really obvious but there is a lot of disagreement on domain objects and their persistence via a repository so it's hard to get a clear answer on this.
Assuming that
I've built a pure domain model that has NO dependencies on any other assemblies within my solution as DDD states with only one clear root aggregate.
I have a domain specific repository that persists the root aggregate,invoked by the service layer.
Internally the repository uses EF to persist the object along with its children
If avoid exposing getters (and definitely not setters) then how does my repository get access to the state of the object in order to actually persist it.
Options??
Dependency injection into the domain model (DDD smell??)
Getters only (DDD smell??)
Also there is the reverse issue pulling objects out of the DB. Initialisation via the constructor seems the only likely candidate.
An ORM can get to the data inside objects via reflection. For example, NHibernate has various access strategies for properties which allow mapped classes to only have private fields with no getters or setters. I think EF should have similar facilities.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With