One of the things my entity classes do (or technically, the strategy classes attached to them do) is set defaults for new transient instances. It will not be uncommon to need to set a default value for a related many-to-one property. Back in the SQL/ADO world, this was a simple matter of setting the desired foreign key value. With objects, I need to set my entity's many-to-one property to a loaded, persistent instance of the related entity.
Where/how do I do that loading? My domain layer doesn't (yet) know how to load persistent entities. I already have a service layer encapsulating NHibernate, so I could define an interface for our service layer in the domain layer, implement that interface in the service layer, and then on application startup register the service layer implementation with the domain layer. But is there a better way?
|