Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Wuyiju.Model.RoleUser model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update RoleUser set ");

            sql.Append(" role_id = @role_id , ");
            sql.Append(" user_id = @user_id  ");
            sql.Append(" where  ");

            DynamicParameters param = new DynamicParameters();

            if (model != null)
            {
                param.AddDynamicParams(model);
            }

            var rows = db.Execute(sql, param);

            if (rows < 1)
            {
                throw new ApplicationException("更新数据无效");
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Insert(Wuyiju.Model.RoleUser model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_role_user(");
            sql.Append("role_id,user_id");
            sql.Append(") values (");
            sql.Append("@role_id,@user_id");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

            if (model != null)
            {
                param.AddDynamicParams(model);
            }

            var rows = db.Execute(sql, param);

            if (rows < 1)
            {
                throw new ApplicationException("插入数据无效");
            }
        }