Example #1
0
        internal void Update()
        {
            var sb = new System.Text.StringBuilder();

            sb.AppendLine("UPDATE users SET");
            sb.AppendLine(" name = @name");
            sb.AppendLine(",real_name = @real_name");
            sb.AppendLine(",age = @age");
            sb.AppendLine(",height = @height");
            sb.AppendLine(",weight = @weight");
            sb.AppendLine(",blood_type = @blood_type");
            sb.AppendLine(",race = @race");
            sb.AppendLine(",guild_name = @guild_name");
            sb.AppendLine(",hobby = @hobby");
            sb.AppendLine(",character_voice = @character_voice");
            sb.AppendLine(",birth_month = @birth_month");
            sb.AppendLine(",birth_day = @birth_day");
            sb.AppendLine("WHERE");
            sb.AppendLine("cd = @cd");
            var param = new Dictionary <string, object> {
                { "name", this.Name },
                { "real_name", this.RealName },
                { "age", this.Age },
                { "height", this.Height },
                { "weight", this.Weight },
                { "blood_type", this.BloodType },
                { "race", this.Race },
                { "guild_name", this.GuildName },
                { "hobby", this.Hobby },
                { "character_voice", this.CV },
                { "birth_month", this.BirthMonth },
                { "birth_day", this.BirthDay }
            };

            using (var q = new SQLiteQuery())
                using (var trans = q.BeginTransaction()) {
                    try {
                        q.ExecuteNonQuery(sb.ToString(), param);
                        trans.Commit();
                    } catch {
                        trans.Rollback();
                        throw;
                    }
                }
        }
Example #2
0
        internal void Delete()
        {
            var sb = new System.Text.StringBuilder();

            sb.AppendLine("DELETE FROM users");
            sb.AppendLine("WHERE");
            sb.AppendLine("cd = @CD");

            using (var q = new SQLiteQuery())
                using (var trans = q.BeginTransaction()) {
                    try {
                        q.ExecuteNonQuery(sb.ToString(), new Dictionary <string, object> {
                            { "cd", this.Cd }
                        });
                        trans.Commit();
                    } catch  {
                        trans.Rollback();
                        throw;
                    }
                }
        }