Example #1
0
        public override void Insert(NpgsqlConnection connection, NpgsqlTransaction transaction)
        {
            if (Id != 0)
            {
                throw new InvalidOperationException("Cannot insert existing row");
            }

            var cmd = new SqlCommand("INSERT INTO rohbot.chathistory (type,date,chat,content,state,\"for\",forid,fortype,forstyle,by,byid,bytype,bystyle)" +
                                     "VALUES (:type,:date,:chat,:content,:state,:for,:forid,:fortype,:forstyle,:by,:byid,:bytype,:bystyle) RETURNING id;", connection, transaction);

            cmd["type"]     = Type;
            cmd["date"]     = Date;
            cmd["chat"]     = Chat;
            cmd["content"]  = Content;
            cmd["state"]    = State;
            cmd["for"]      = For;
            cmd["forid"]    = ForId;
            cmd["fortype"]  = ForType;
            cmd["forstyle"] = ForStyle;
            cmd["by"]       = By;
            cmd["byid"]     = ById;
            cmd["bytype"]   = ByType;
            cmd["bystyle"]  = ByStyle;
            Id = (long)cmd.ExecuteScalarNoDispose();
        }
Example #2
0
        public override void Insert(NpgsqlConnection connection, NpgsqlTransaction transaction)
        {
            if (Id != 0)
            {
                throw new InvalidOperationException("Cannot insert existing row");
            }

            var cmd = new SqlCommand("INSERT INTO rohbot.chathistory (type,date,chat,content,usertype,sender,senderid,senderstyle,ingame)" +
                                     "VALUES (:type,:date,:chat,:content,:usertype,:sender,:senderid,:senderstyle,:ingame) RETURNING id;", connection, transaction);

            cmd["type"]        = Type;
            cmd["date"]        = Date;
            cmd["chat"]        = Chat;
            cmd["content"]     = Content;
            cmd["usertype"]    = UserType;
            cmd["sender"]      = Sender;
            cmd["senderid"]    = SenderId;
            cmd["senderstyle"] = SenderStyle;
            cmd["ingame"]      = InGame;
            Id = (long)cmd.ExecuteScalarNoDispose();
        }