I'm exploring the offerings of an ORM (focusing on NHibernate, considering all options) and am convinced that using one could be a great benefit for some of our projects--however I'm having a hard time picturing just how it would play in our system.
My understanding is that an ORM is ideally used to glue together a database and business logic. This assumes the business logic has access to a database, but in our system we have web-services stuck in the middle.
Our current system is fairly simple. We are .NET thru-and-thru and have:
- Databases. With tables... and rows.
- Permissions are limited to execute rights on sprocs, we build sprocs with basic validation and nothing goes into or out of the database without going through a sproc.
- WebServices
- Perform CRUD operations against the DB sprocs
- Currently typically use DataSets/DataTables for their messages
- Business Logic
- Talks to the web services
Adding an ORM to the mix seems to logically put it between the database and webservice. So the client would make a request to the service, the service would use the ORM to retrieve the results as objects instead of as DataTables, and the client would receive objects from the web-service.
So my barage of questions is:
Does that approach work?
- Do any particular ORMs favor this type of approach? Are any major ORMs particularly ill-suited to this environment?
Is there another implementation that would place some of the ORM interaction on the client-side of the web-service (have the client request an object from the ORM provider and have the ORM provider wrap the web-service communication)?
Our current unit-of-work focuses on DataTables and their row-state tracking.
- How much of the state-tracking would an ORM provide when we stick a webservice between it and the business logic?
- Would the objects we map to be required to provide their own state-tracking?