public AccountOBJ GetAccount(AccountOBJ entity, bool AutoCreate = false) { IDbEntity that = Get(entity); if (that != null) { return((AccountOBJ)that); } CHeck(); Users usr = session.QueryOver <Users>().Where(x => x.UserName == entity.Username).List().FirstOrDefault(); if (usr != null) { AccountOBJ account = GetAccountFromDB(usr.UserName); ENTITY.Add(account.GetId(), account); return(account); } else { if (AutoCreate) { AccountOBJ user = new AccountOBJ((Users)entity.GetEntity()); using (ITransaction transaction = session.BeginTransaction()) { user.Id = (uint)session.Save(user.GetEntity()); transaction.Commit(); } return(GetAccount(user)); } } return(null); }
private IDbEntity Get(AccountOBJ entity) { if (ENTITY.TryGetValue(entity.GetId(), out IDbEntity Entity)) { return(Entity); } return(null); }