view Agendas/trunk/src/Agendas.Repositories.NHibernate/RepositoryBase.cs @ 144:a2b14da4902f

Alta y modificación de ponentes (personas)
author Nelo@Guinea.neluz.int
date Mon, 01 Aug 2011 10:25:23 -0300
parents 963b71ea6028
children 70c5cab59054
line wrap: on
line source

using System;
using AltNetHispano.Agendas.Domain;
using NHibernate;

namespace AltNetHispano.Agendas.Repositories.NHibernate
{
	public class RepositoryBase<T> where T : Identificable
	{
		private readonly ISessionFactory _sessionFactory;

		public RepositoryBase(ISessionFactory sessionFactory)
		{
			_sessionFactory = sessionFactory;
		}

		protected ISession Session { get { return _sessionFactory.GetCurrentSession(); } }

		public void Save(T obj)
		{
			Session.Save(obj);
		}

        public T Get(Guid id)
        {
            return Session.QueryOver<T>().Where(i => i.Id == id).SingleOrDefault();
        }

	}
}