Skip to content

Instantly share code, notes, and snippets.

@dgomesbr
Created February 9, 2012 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgomesbr/1782792 to your computer and use it in GitHub Desktop.
Save dgomesbr/1782792 to your computer and use it in GitHub Desktop.
Implementação do repositório genérico
using System.Collections.Generic;
using workshop_httpmodule;
namespace Workshop.Data.NHibernate
{
public class GenericRepository<T> : IRepository<T>
{
public T Save(T entity)
{
NHibernateHttpModule.RecuperarSessao.Save(entity);
return entity;
}
public T Update(T entity)
{
NHibernateHttpModule.RecuperarSessao.Update(entity);
return entity;
}
public void Delete(T entity)
{
NHibernateHttpModule.RecuperarSessao.Delete(entity);
}
public T ById(int id)
{
return NHibernateHttpModule.RecuperarSessao.Get<T>(id);
}
public IList<T> All()
{
return NHibernateHttpModule.RecuperarSessao.CreateCriteria(typeof(T)).List<T>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment