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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:28:26+00:00 2026-05-23T14:28:26+00:00

NHibernate’s Session and EF’s ObjectContext are implementations of Unit of Work pattern and suggest

  • 0

NHibernate’s Session and EF’s ObjectContext are implementations of Unit of Work pattern and suggest similar approaches for change tracking: you retrieve some entities, then modify them somehow and after that call SaveChanges/SubmitChanges/Save/etc.

I don’t like the implicitness of this approach. I don’t like that entity modification automatically means it will be saved. I would like to explicitly mark entities that should be saved. What are the best ways to achieve this kind of control in NHibernate or EF?

  • 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-23T14:28:26+00:00Added an answer on May 23, 2026 at 2:28 pm

    (note: fortunately I’ve never dealt with EF; my answer is about NH only)
    I think your initial assumption is wrong:

    entity modification automatically
    means it will be saved

    that’s not true; in order to persist the changes you’ve made you need to either:

    1. call Session.Flush() yourself
    2. set Session’s flush mode to AutoCommit (highly not recommended)
    3. use an ITransaction and commit it (by far the best approach).

    unless you do any of the above your changes would not be persisted.
    Personally I feel that NH gives me complete control over what goes into my DB.

    here’s a good article.

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

Sidebar

Related Questions

Using NHibernate 2.0: I have an object with some changes on it and I
NHibernate. I'm work with sql compaq edition, and I have many tables, I need
NHibernate's first level cache is available when one use same session. ActiveRecordBase.FindAll() each time
Can NHibernate update some (not all) fields in the table row without retrieving any
NHibernate seems to have some new ways to map entities in code, which is
NHibernate.Context.WebSessionContext , otherwise known as web session context , plays nicely with ASP.NET, but
Does NHibernate internally implement UnitOfWork Pattern? If NOT, What are the cases when I
I'm learning Fluent NHibernate (and by extension, NHibernate generally). I'm using auto-mapping with some
NHibernate is not really a good fit for our environment due to all the
NHibernate is driving me 'Nuts'!!! I have the following mapping. Which returns this error

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.