示例#1
0
 public void SaveObject <T>(T entity) where T : BaseEntity
 {
     if (entity.Id.GetType() == typeof(int) && entity.Id == 0)
     {
         entity.SetId(GenerateNewId(NHibernateDatabaseFactory.TableName <T>()));
     }
     GetSession().Save(entity);
     GetSession().Flush();
 }
示例#2
0
        public ISession GetSession()
        {
            ISession session = NHibernateDatabaseFactory.GetSession();

            if (!session.IsConnected)
            {
                session.Reconnect();
            }
            return(session);
        }
示例#3
0
        public void Save(TEntity entity)
        {
            if (entity.Id.GetType() == typeof(int) && entity.Id == 0)
            {
                entity.SetId(GenerateNewId(NHibernateDatabaseFactory.TableName(entity.GetType())));
            }
            ISession session = GetSession();

            session.Save(entity);
            session.Flush();
        }