Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.NHibernate/SessionScope.cs @ 179:1deccd6c3cb2
Aplicando seguridad x roles en sitio web
author | nelopauselli |
---|---|
date | Mon, 08 Aug 2011 15:24:26 -0300 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
178:33e57fd1a6c9 | 179:1deccd6c3cb2 |
---|---|
1 using System; | |
2 using NHibernate; | |
3 using NHibernate.Context; | |
4 | |
5 namespace Agendas.NHibernate | |
6 { | |
7 public class SessionScope : IDisposable | |
8 { | |
9 private readonly ISessionFactory _sessionFactory; | |
10 | |
11 public SessionScope(ISessionFactory sessionFactory) | |
12 { | |
13 _sessionFactory = sessionFactory; | |
14 | |
15 var session = _sessionFactory.OpenSession(); | |
16 CurrentSessionContext.Bind(session); | |
17 } | |
18 | |
19 public void Dispose() | |
20 { | |
21 var session = _sessionFactory.GetCurrentSession(); | |
22 | |
23 session.Flush(); | |
24 session.Close(); | |
25 } | |
26 } | |
27 } |