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(); }
public ISession GetSession() { ISession session = NHibernateDatabaseFactory.GetSession(); if (!session.IsConnected) { session.Reconnect(); } return(session); }
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(); }