annotate Agendas/trunk/src/Agendas.Repositories.NHibernate/RepositoryBase.cs @ 164:93aa103f75ec

Merge
author nelopauselli
date Fri, 05 Aug 2011 21:55:45 -0300
parents a2b14da4902f
children 70c5cab59054
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
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
11 public RepositoryBase(ISessionFactory sessionFactory)
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 {
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
25 return Session.QueryOver<T>().Where(i => i.Id == id).SingleOrDefault();
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
26 }
a2b14da4902f Alta y modificación de ponentes (personas)
Nelo@Guinea.neluz.int
parents: 63
diff changeset
27
63
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
28 }
963b71ea6028 Repositorios con NH
nelopauselli
parents:
diff changeset
29 }