fox_psvjlp@trashmail.net wrote:
Dear NHibernate experts.
I have a design problem here, which is not really linked to NH but
more to the way C# works.
I work on a classical 3 layer application, Data layer (with NH),
Business layer, and UI Layer.
I don't want to couple the UI layer to the Data layer but I have the
following situation that enforces me to add a reference to the
NHibernate dll in the UI project.
I have nh mapped class that travel from the data layer to the ui
layer, and vice versa. So all 3 layer need to reference the project
containing those objects in order to manipulate them.
Here is the problem. One of my mapped nhibernate domain object class
implements ILifecycle in order to hook up life cycle events. Let's
call this class myDomainObject.
Because the UI displays that object, C# requires that the UI project
"knows about" the ILifecycle interface, that is to say, I must add a
reference to NH in the UI project.
Indeed C# does not support private inheritance as C++.
Question. Is that ok ? Is the design poor ?
Thanks.
I want to respond with a question. :)
If you do not have a reference to the NHibernate dll in your UI, which part of your application is responsible for opening and closing connections (sessions) and for starting / committing / rollbacking transactions ?
In other words: which part of your application does know the context of when a new connection needs to be opened, or when a transaction needs to be started (or committed) ?