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