Making OR/M loosely coupled and abstracted away from other layers.
Posted
by Genuine
on Stack Overflow
See other posts from Stack Overflow
or by Genuine
Published on 2010-03-26T21:20:28Z
Indexed on
2010/03/26
21:23 UTC
Read the original article
Hit count: 248
Hi all.
In an n-tier architecture, the best place to put an object-relational mapping (OR/M) code is in the data access layer. For example, database queries and updates can be delegated to a tool like NHibernate.
Yet, I'd like to keep all references to NHibernate within the data access layer and abstract dependencies away from the layers below or above it. That way, I can swap or plug in another OR/M tool (e.g. Entity Framework) or some approach (e.g. plain vanilla stored procedure calls, mock objects) without causing compile-time errors or a major overhaul of the entire application. Testability is an added bonus.
Could someone please suggest a wrapper (i.e. an interface or base class) or approach that would keep OR/M loosely coupled and contained in 1 layer? Or point me to resources that would help?
Thanks.
© Stack Overflow or respective owner