public TEntity GetById <TEntity>(Guid id) where TEntity : BaseEntity { using (ISession session = FluentNHibertnateSession.OpenSession()) { return(session.Get <TEntity>(id)); } }
public List <TEntity> GetAll <TEntity>() where TEntity : BaseEntity { using (ISession session = FluentNHibertnateSession.OpenSession()) { return(session.Query <TEntity>().ToList()); } }
public List <TEntity> Filter <TEntity>(Func <TEntity, bool> condition) where TEntity : BaseEntity { using (ISession session = FluentNHibertnateSession.OpenSession()) { return(session.Query <TEntity>() .Where(condition) .ToList()); } }
public void AddOrUpdate <TEntity>(TEntity entity) where TEntity : BaseEntity { using (ISession session = FluentNHibertnateSession.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { session.SaveOrUpdate(entity); transaction.Commit(); } } }