Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1046313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:07:39+00:00 2026-05-16T16:07:39+00:00

The application uses ADO.NET to invoke sprocs for nearly every database operation. Some of

  • 0

The application uses ADO.NET to invoke sprocs for nearly every database operation. Some of these sprocs also contain a fair amount of domain logic. The data access logic for each domain entity resides in the domain class itself. ie, there is no decoupling between domain logic and data access logic.

I’m looking to accomplish the following:

  • decouple the domain logic from the data access logic
  • make the domain model persistence ignorant
  • implement the transition to NHibernate gradually across releases, refactoring individual portions of the DAL (if you can call it that) at a time

Here’s my approach for transitioning a single class to NHibernate persistence

  1. create a mapping for the domain class
  2. create a repository for the domain class (basic CRUD operations inherited from a generic base repository)
  3. create a method in the repository for each sproc used by the old DAL (doing some refactoring along the way to pull out the domain logic)
  4. modify consumers to use the repository rather than the data access logic in the class itself
  5. remove the old data access logic and the sprocs

The issues I have are with #1 and #4.

(#1) How can I map properties of a type with no NHibernate mapping?

Consider a Person class with an Address property (Address being a domain object without an NH mapping and Person being the class I’m mapping). How can I include Address in the Person mapping without creating an entire mapping for Address?

(#4) How should I manage the dependencies on old data access logic during the transition?

Classes in the domain model utilize the old data access logic that I’m looking to remove. Consider an Order class with a CustomerId property. When the Order needs info on the Customer it invokes the ADO.NET data access logic that resides in the Customer class. What options are there other than maintaining the old data access logic until the dependent classes are mapped themselves?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:07:39+00:00Added an answer on May 16, 2026 at 4:07 pm

    I would approach it like this:

    1. Refactor and move the data access logic out of the domain classes into a data layer.
    2. Refactor and move the domain logic out of the sprocs into a data layer. (This step is optional, but doing it will definitely make the transition smoother and easier.)
    3. You don’t need a repository, but you can certainly create one if you want.
    4. Create a NHibernate mapping for every domain class (there are tools that do this).
    5. Create a NHibernate oriented data access API that slowly replaces the sproc data layer.

    Steps 1 & 2 are the hardest part as it sounds like you have tight coupling that ideally never would have happened. Neither of these first two steps involve NHibernate at all. You are strictly moving to a more maintainable architecture before trying to swap out your data layer.

    While it may be possible to create NHibernate mappings one by one and utilize them without the full object graph being available, that seems like asking for unnecessary pain. You need to proceed very cautiously if you choose that path and I just wouldn’t recommend it. To do so, you may leave a foreign key mapped as a plain int/guid instead of as a relation to another domain class, but you have to be very careful you don’t corrupt your data by half committing to NHibernate in that way. Automated unit/integration tests are your friend.

    Swapping out a data layer is hard. It is easier if you have a solid lowest common denominator data layer architecture, but I wouldn’t actually recommend creating an architecture using a lowest common denominator approach. Loose coupling is good, but you can go too far.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I develop desktop-based WPF-application, that uses SQL Server 2008 R2 Database and ADO.NET Entity
My application uses Google Charts and using HTTPS. I need to display the Google
My application uses the sfDoctrineGuardPlugin to secure the application and force uses to login
My application uses a list of media files on the phone, i.e. images, audio
My JSF web application uses PrimeFaces Captcha. It works properly under Firefox and IE,
My document-based Cocoa application uses a NSOutlineView/NSTreeController combo, bound to the document's Core Data
I've been considering how you would write a business application in only F# with
// MS SQL Server 2008. My application has several different connections to sql server
When learning the C# language. With all the applications being developed these days. Would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.