I'm developing a web service using NHibernate, WCF and Oracle 11g R1. The web service is pretty simple: it maps DTOs to POCOs and performs various CRUD operations on them based on the operation called. Each entity has its own set of CRUD methods - this is a temporary, but necessary for the time being.
I'm looking for input on a good Repository pattern that will support this 1:1 CRUD service layer now and not be entirely thrown away when the API needs to become more robust. Right now consumers will update entities using this service "piece-by-piece", but later, these operations will be more robust. I.e. A service operation will work with more than one entity.
So, as an example I have entities A, B and C. There will be CRUD service operations for A, B, and C. Currently, when the consumer works with A locally, it's most always also working with B and C. When it uses the service to interact A, B and C, it will need to make three separate service calls. The majority of the business logic is residing on the consumer for now, but when that moves into the service layer, an service operation will be created so that it can work with A, B and C in one call.
I've done a fair amount of Googling on the Repository pattern and NHibernate (and WCF), thus far I've read:
http://daniel.wertheim.se/2009/10/21/nhibernate-hbmnhibcontext-fluentnhibcontext/ http://stackoverflow.com/questions/895988/nhibernate-session-management-in-wcf-application http://davybrion.com/blog/2008/06/managing-your-nhibernate-sessions/ http://davybrion.com/blog/2009/12/using-nhibernate-in-your-service-layer/ http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-repository-classes-simple/
And a bunch others. Two basic things I want to achieve:
- One ISession per request
- One ITransaction per request
I thought it would make sense to have a Repository per entity now and then eventually some type of aggregate root Repository could be added on top of those when then service operations were made more complex. Would that even be necessary?
Thanks.