annotate Agendas/trunk/src/Agendas.Repositories.NHibernate/RepositoryBase.cs @ 257:730b80afa70d

Ticket #191: Perfil de Usuarios
author juanjose.montesdeocaarbos
date Wed, 19 Oct 2011 09:19:20 -0300
parents 70c5cab59054
children
rev   line source
144
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
1 using System;
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
2 using AltNetHispano.Agendas.Domain;
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
3 using NHibernate;
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
4
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
5 namespace AltNetHispano.Agendas.Repositories.NHibernate
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
6 {
144
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
7 public class RepositoryBase<T> where T : Identificable
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
8 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
9 private readonly ISessionFactory _sessionFactory;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
10
246
70c5cab59054 refactor menor en repositorios
nelopauselli
parents: 144
diff changeset
11 protected RepositoryBase(ISessionFactory sessionFactory)
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
12 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
13 _sessionFactory = sessionFactory;
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
14 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
15
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
16 protected ISession Session { get { return _sessionFactory.GetCurrentSession(); } }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
17
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
18 public void Save(T obj)
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
19 {
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
20 Session.Save(obj);
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
21 }
144
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
22
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
23 public T Get(Guid id)
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
24 {
246
70c5cab59054 refactor menor en repositorios
nelopauselli
parents: 144
diff changeset
25 return Session.Get<T>(id);
70c5cab59054 refactor menor en repositorios
nelopauselli
parents: 144
diff changeset
26 //return Session.QueryOver<T>().Where(i => i.Id == id).SingleOrDefault();
144
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
27 }
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
28
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
29 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
30 }