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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:05:38+00:00 2026-05-23T16:05:38+00:00

From NHibernate documentation , it doesn’t explain much. What is the difference between those

  • 0

From NHibernate documentation, it doesn’t explain much.

What is the difference between those three ?

In what situation that one of those context is more preferable than the others ?

P.S. ThreadLocalSessionContext doesn’t exist in the documentation, but it does exist in NHibernate dll.

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

    It doesn’t look like ThreadLocalSessionContext can currently be used. There is no configuration that supports it’s use and it’s only referenced within NHibernate by a unit test.

    According to the code CallSessionContext is a way of handling sessions in .Net remoting see comments in code below for more detail. It looks like NHibernate basically stores the session in the remoting call context. More info about remoting call contexts can be found here

    /// <summary>
    /// Provides a <see cref="ISessionFactory.GetCurrentSession()">current session</see>
    /// for each <see cref="System.Runtime.Remoting.Messaging.CallContext"/>.
    /// Not recommended for .NET 2.0 web applications.
    

    ThreadStaticSessionContext is used for handling sessions in multi-threaded applications. It uses a [ThreadStatic] attribute to declare the session such that there is a session per thread. I currently use this. See this SO link for a code example of how you would use it: What is the best NHibernate session management approach for using in a multithread windows service application?

    Also in addition to this it looks like NHibernate is adding another session context in version 3.2 called WcfOperationSessionContext. Below is the description from the code:

    /// <summary>
    /// Provides a <see cref="ISessionFactory.GetCurrentSession()">current session</see>
    /// for the current OperationContext in WCF. Works only during the lifetime of a WCF operation.
    /// </summary>
    

    To answer your 2nd question it really depends on what type of application you are implementing and how you are using your sessions. Hopefully between the nhibernate documentation and the descriptions above you’ll have a better idea of what context you should use.

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

Sidebar

Related Questions

Using NHibernate from C# and only HQL (not SQL) in a way that is
I am just learning NHibernate. I have been using examples from the documentation and
Documentation on NHibernate cascade settings, discusses the settings in the context of calling the
I am getting the folloinwg error from NHibernate: System.ObjectDisposedException: Session is closed! Object name:
How can I change the connection string from nhibernate.config file using nant the problem
What kinds of considerations are there for migrating an application from NHibernate 1.2 to
What tool is there for generating C# classes from NHibernate mappings files?
How can I get specific number of records from nhibernate like 10 or 15
Is it possible to generate the database tables and c# classes from NHibernate config
What I want to do is convert my whole application to nhibernate from ADO.NET

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.