Hi,
I'm new to NHibernate but have used ORM in a previous ASP.NET project with the following architecture:
Domain (OR mapped using non-POCO NPersist)
Service Layer
UI
The service layer was built using static methods that accepted primitive types only along with a reference to the persistence framework context. For example:
public static Customer CustomerServices.GetByID(Context context, int id)
public static int CustomerServices.Add(Context context, string name, DateTime dateOfBirth)
The persistence framework context was initialised in OnInit and disposed of in OnUnload and this was contained in a base page within the UI.
The service layer methods would begin, commit and rollback transactions as required by calling appropriate methods on the NPersist context.
Is this a good standard to apply to NHib as well, simply replacing the NPersist context with an NHib session or is it better for the UI to be completely unaware of the session? How about just passing primitive types into the service layer as opposed to domain objects...is this good practice? For example an alternative Add for a customer might be:
public static void CustomerServices.Add(Customer customer)
This would mean that the customer object is created in the UI and then just passed in to the service layer.
Any guidance is greatly appreciated.
Thanks,
Jason
|