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

  • Home
  • SEARCH
  • 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 6080241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:02:20+00:00 2026-05-23T11:02:20+00:00

In Entity Framework 4.1 (Code First), each DbSet in a DbContext has a .Local

  • 0

In Entity Framework 4.1 (Code First), each DbSet in a DbContext has a .Local collection of entities that have been added to the context but not yet saved.

In NHibernate 3.1, when I create an entity and save it, it does not commit to the database until the session is flushed. I can either call Session.Flush manually, or rely on automatic flushing when the transaction is committed.

But before the session is flushed, how can I query the session for the unflushed entities? In EF, I could look at DbSet.Local, but I don’t see any equivelent in NHibernate. If I’ve lost reference to the newly created entity but my session is still open and unflushed, is there no way to get the entity back without committing the changes and requerying the database?

  • 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-23T11:02:20+00:00Added an answer on May 23, 2026 at 11:02 am

    NHibernate does not expose anything like EF’s DbSet.Local.

    An easy way to implement this is to keep a list in your repository class (you’d have to create it if you don’t have one)

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

Sidebar

Related Questions

I have been using Entity Framework CTP with Code-First as in this tutorial by
I have a small MVC 3 app using Entity Framework Code First and use
Using the Entity Framework Code First paradigm I have defined the following objects and
I'm having trouble mapping two entities together with Entity Framework CTP5 using Code First
Using the Entity Framework 4. I have created a Code First database in the
Using Entity Framework 4 and code first how would I create a model that
I am working with Entity Framework Code first. I have a simple model: public
I'm using Entity Framework Code First. Usually I have no problem, but for a
I've noticed that, by default, Entity Framework Code First neglects to instantiate ICollection<T> properties
I'm using Entity Framework Code First and whilst I have working code, I'm having

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.