public bool AddToCache(User user, string deviceType) { var obj = new OnlineUser { UserId = user.Id }; obj.SetCreateDate(); obj.SetNewId(); obj.SetRowAdded(); obj.Token = Guid.NewGuid().ToString().EncryptByMD5(); obj.DeviceType = deviceType; var entities = new List <EntityBase> { obj }; var cmd = CommandHelper.CreateSave(entities); cmd.PreCommands = new List <Command> { AttachDeleteToken(user.Id, deviceType) }; DbContext.GetInstance().Execute(cmd); user.DeviceType = obj.DeviceType; user.Token = obj.Token; return(true); }