I'm working on a new common .NET software design (mainly) for WCF-based web service applications with related client frontends (all written in C#). As far I've chosen some frameworks (NUnit,Autofac/Castle Windsor) as basis for the application.
Now I'm doing some research concerning db abstraction. I'm considering NHibernate (together with FluentNHibernate) as persistence framework. But there are some concerns about NHibernate.
Database interfaces provided by our db dev team heavily rely on stored procedures and often use UDT objects as output parameters (sometimes also ref cursors). Many already existing applications are using auto-generated UDT C# classes.
NHibernate seems to work well with Oracle (with appropriate configuration and usage of ODP.NET). See Fluent NHibernate - how to configure for oracle?, Fluent NHibernate - Configure Oracle Data Provider ODP. Also ref cursors and stored procedure calls seem to work with nhibernate (see Calling an Oracle store procedure with nHibernate and Oracle stored procedures, SYS_REFCURSOR and NHibernate).
Is it appropriate to use NHibernate in this case (stored procedures and UDT/ref cursor output)? Or would it be better to keep auto-generated UDT C# classes and implement custom data access objects?
Design A (with auto-generated UDT classes):
- Create business objects in the domain model (e.g.
class Product
) - Define database-independent interfaces e.g.
IDataAccessProduct
. - Implement it in classes e.g.
OracleDataAccessProduct
that represent specific data access objects. For example this class calls performs a mapping of auto-generated UDT classes (entities) toProduct
domain objects and vice versa.
Design B (with NHibernate):
- Create business objects in the domain model (e.g. entity class
Product : IEntity<Product>
.) - Add interface an IProductRepository for the repository. In the domain model. Add
ProductRepository
that extends the e.g. base classRhino.Commons.NHRepository
. - Usage of hibernate-mapping for domain objects to db table (
Product.hbm.xml
).
So which design would you prefer?