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 3846678
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:26:04+00:00 2026-05-19T16:26:04+00:00

Taking the traditional 3 layer approach (not necessarily 3 tiers): UI BLL DAL How

  • 0

Taking the traditional 3 layer approach (not necessarily 3 tiers):

UI
BLL
DAL

How does NHibernate fit? In most cases I see people allowing NHibernate to directly populate domain objects/entities, which obviously requires a reference from NHibernate to these entities. If domain entities are part of the BLL, this seems to require a reference from the DAL (where NHibernate resides) to the BLL (where domain objects reside).

Doesn’t this go against the typical thinking of separating each layer, with each layer only being dependent on the one below it? What am I missing here?

  • 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-19T16:26:05+00:00Added an answer on May 19, 2026 at 4:26 pm

    I can give you an example, how I generally layer with NHibernate for a n-tier architecture:

    Data Access Layer

    • NHibernate SessionFactory
    • Mappings with FluentNHibernate

    Example for a mapping:

    public class CategoryMap : ClassMap<Domain.Entities.Category>
    {
        public CategoryMap()
        {
            ...
        }
    }
    

    Business Layer

    • Repositories : BaseRepository

    Example for a repository:

    public class CategoryRepository : BaseRepository<Domain.Entities.Category>,
        Domain.DataInterfaces.Business.Repositories.ICategoryRepository
    {
        public CategoryRepository(ISession session)
            : base(session)
        {
        }
    }
    
    • BaseRepository (CRUD, GetById, GetAll)

    Example for a base repository:

    public class BaseRepository<T> : IBaseRepository<T>
    {
        public ISession Session { get; set; }
    
        public BaseRepository(ISession session)
        {
            Session = session;
        }
     }
    

    Domain Layer

    • DataInterfaces (IRepository, IBaseRepository)
    • Entities : BaseEntity
    • Persistance (IEntity, IBaseEnity)

    So, the only layer which is referencing NHibernate is actually the data layer and the business (NHibernate.ISession). The domain layer is shared between all layers and does not know about NHibernate. For simplicy you could merge the business and data layer into one layer. I generally tend to seperate them, but it depends on the project size.

    enter image description here

    If you really want seperation, I also suggest you to have a look at dependency injection to reduce the dependencies between different layers.

    Hope that helps you.

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

Sidebar

Related Questions

Why Textarea and textfield not taking font-family and font-size from body? See live example
The host that I want to host with does not support server side url
Taking this basic example of jQuery Validate (see link below), how can you instruct
Taking the database first approach in MVC3 all of my models are created and
Taking over some code from my predecessor and I found a query that uses
Taking shs's question a step further... Why isn't all government sponsored software open source?
Taking advice from this post , I purchased a copy of 'The C Programming
Taking CPU affinity into account, will such an environment be useful with threading? Or
Taking this article on classes and structs as an example: http://msdn.microsoft.com/en-us/library/ms173109.aspx namespace ProgrammingGuide {
Taking out all of the obvious caveats related to benchmarks and benchmark comparison, is

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.