Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

SessionScope Class

Implementation of SessionScope that associates a single session within the using scope.

For a list of all members of this type, see SessionScope Members .

System.Object
   SessionScope
      OpenSessionInViewModule
      OpenSessionInViewModule
      OpenSessionInViewModule

[Visual Basic]
Public Class SessionScope
    Implements IDisposable
[C#]
public class SessionScope : IDisposable

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

It is recommended to be used in the following type of scenario:

using (new SessionScope())
{
   ... do multiple operation, possibly in multiple transactions. 
}
At the end of "using", the session is automatically closed. All transactions within the scope use the same session, if you are using Spring's HibernateTemplate or using Spring's implementation of NHibernate 1.2's ICurrentSessionContext interface.

It is assumed that the session factory object name is called "SessionFactory". In case that you named the object in different way you can specify your can specify it in the application settings using the key Spring.Data.NHibernate.Support.SessionScope.SessionFactoryObjectName. Values for EntityInterceptorObjectName and SingleSessionMode can be specified similarly.

Note: The session is managed on a per thread basis on the thread that opens the scope instance. This means that you must never pass a reference to a SessionScope instance over to another thread!

Requirements

Namespace: Spring.Data.NHibernate.Support

Assembly: Spring.Data.NHibernate20 (in Spring.Data.NHibernate20.dll)

See Also

SessionScope Members | Spring.Data.NHibernate.Support Namespace