Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

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) to Product 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 class Rhino.Commons.NHRepository.
  • Usage of hibernate-mapping for domain objects to db table (Product.hbm.xml).

So which design would you prefer?

share|improve this question

migrated from stackoverflow.com Apr 3 '13 at 15:30

This question came from our site for professional and enthusiast programmers.

1 Answer 1

nHibernate, Entity Framework and other ORM (Object Relational Mapping) tools are wonderful to represent abstractions of the database objects (Tables/Views), relationships and keys through true business objects in the data layer of an application. The motive around the ORM tools are to make the data layer robust and to support Rapid Application Development (RAD) through different design time support in Visual Studio to map and represent database objects and relationships in the data layer. ODP .Net UDT to some extent support all these philosophies. However, if you would like to truley provide complete object relational abstraction in data layer, either nHibernate or Entity Framework should be used.

share|improve this answer
1  
this post is rather hard to read (wall of text). Would you mind editing it into a better shape? –  gnat Feb 16 at 20:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.