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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:43:04+00:00 2026-05-16T06:43:04+00:00

I’m developing a web service using NHibernate, WCF and Oracle 11g R1. The web

  • 0

I’m developing a web service using NHibernate, WCF and Oracle 11g R1. The web service is pretty simple: it maps DTOs to POCOs and performs various CRUD operations on them based on the operation called. Each entity has its own set of CRUD methods – this is a temporary, but necessary for the time being.

I’m looking for input on a good Repository pattern that will support this 1:1 CRUD service layer now and not be entirely thrown away when the API needs to become more robust. Right now consumers will update entities using this service “piece-by-piece”, but later, these operations will be more robust. I.e. A service operation will work with more than one entity.

So, as an example I have entities A, B and C. There will be CRUD service operations for A, B, and C. Currently, when the consumer works with A locally, it’s most always also working with B and C. When it uses the service to interact A, B and C, it will need to make three separate service calls. The majority of the business logic is residing on the consumer for now, but when that moves into the service layer, an service operation will be created so that it can work with A, B and C in one call.

I’ve done a fair amount of Googling on the Repository pattern and NHibernate (and WCF), thus far I’ve read:

http://daniel.wertheim.se/2009/10/21/nhibernate-hbmnhibcontext-fluentnhibcontext/
NHibernate session management in WCF application
http://davybrion.com/blog/2008/06/managing-your-nhibernate-sessions/
http://davybrion.com/blog/2009/12/using-nhibernate-in-your-service-layer/
http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-repository-classes-simple/

And a bunch others. Two basic things I want to achieve:

  • One ISession per request
  • One ITransaction per request

I thought it would make sense to have a Repository per entity now and then eventually some type of aggregate root Repository could be added on top of those when then service operations were made more complex. Would that even be necessary?

Thanks.

  • 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-16T06:43:05+00:00Added an answer on May 16, 2026 at 6:43 am

    This MSDN article by K Scott Allen combines repositories with the UnitOfWork pattern.

    In the case of NHibernate your UnitOfWork would be created with an NHibernate ISession, and if required you could make each UoW transacted. Obviously the UoW would be responsible for creating the various repositories from the ISession it is provided with…

    public class NHibernateUnitOfWork : IUnitOfWork
    
        public NHibernateUnitOfWork(ISession session)
        {
            // if transacted you would begin the transaction here also
            _session = session;
        }
    
        private ISession _session;
    
        private IRepository<A> _aRepository   
        public IRepository<A> ARepository
        {
            get
            {
                if(_aRepository == null)
                    _aRepository = new NHibernateRepository<A>(_session);
    
                return _aRepository;    
            }
        }
    
        private IRepository<B> _bRepository   
        public IRepository<B> BRepository
        {
            get
            {
                if(_bRepository == null)
                    _bRepository = new NHibernateRepository<B>(_session);
    
                return _bRepository;    
            }
        }
    
        private IRepository<C> _cRepository   
        public IRepository<C> CRepository
        {
            get
            {
                if(_cRepository == null)
                    _cRepository = new NHibernateRepository<C>(_session);
    
                return _cRepository;    
            }
        }
    
        public void Commit()
        {
            // if transacted you would commit the transaction here
            _session.Flush();
        }
    
        public void Dispose()
        {
            _session.Dispose();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm making a simple page using Google Maps API 3. My first. One marker
Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.