예제 #1
0
        /// <summary>
        /// Removes the instance from the database.
        /// </summary>
        public void Remove()
        {
            DbCommand command = DatabaseEngine.Instance.CreateCommand();

            command.CommandText = "delete from Account where AccountId=@AccountId";

            DatabaseEngine.AddLongParameter(command, "@AccountId", this._accountId);

            command.ExecuteNonQuery();
        }
예제 #2
0
        /// <summary>
        /// Writes the Account instance back to the database.
        /// </summary>
        public void Persist()
        {
            if (_dirty)
            {
                DbCommand command = DatabaseEngine.Instance.CreateCommand();

                command.CommandText = "update Account set Bio=@Bio, HitPoints=@HitPoints, Mana=@Mana, PasswordHash=@PasswordHash, PlaneId=@PlaneId, RaceId=@RaceId where AccountId=@AccountId";

                DatabaseEngine.AddLongParameter(command, "@AccountId", this._accountId);

                DatabaseEngine.AddLongParameter(command, "@HitPoints", this._hitPoints);
                DatabaseEngine.AddLongParameter(command, "@PlaneId", this._plane.Elevation);
                DatabaseEngine.AddLongParameter(command, "@RaceId", this._race.RaceId);
                DatabaseEngine.AddLongParameter(command, "@Mana", this._mana);

                DatabaseEngine.AddStringParameter(command, "@Bio", this._bio);
                DatabaseEngine.AddStringParameter(command, "@PasswordHash", this._passwordHash);

                command.ExecuteNonQuery();
            }
        }