/// <summary> /// 更新一条数据 /// </summary> public void Update(Wuyiju.Model.AskReply model) { StringBuilder sql = new StringBuilder(); sql.Append("update AskReply set "); sql.Append(" id = @id , "); sql.Append(" content = @content , "); sql.Append(" user_id = @user_id , "); sql.Append(" ask_id = @ask_id , "); sql.Append(" reply_time = @reply_time , "); sql.Append(" enable = @enable "); sql.Append(" where id=@id "); DynamicParameters param = new DynamicParameters(); if (model != null) { param.AddDynamicParams(model); } var rows = db.Execute(sql, param); if (rows < 1) { throw new ApplicationException("更新数据无效"); } }
/// <summary> /// 增加一条数据 /// </summary> public void Insert(Wuyiju.Model.AskReply model) { StringBuilder sql = new StringBuilder(); sql.Append("insert into ec_ask_reply("); sql.Append("id,content,user_id,ask_id,reply_time,enable"); sql.Append(") values ("); sql.Append("@id,@content,@user_id,@ask_id,@reply_time,@enable"); sql.Append(") "); DynamicParameters param = new DynamicParameters(); if (model != null) { param.AddDynamicParams(model); } var rows = db.Execute(sql, param); if (rows < 1) { throw new ApplicationException("插入数据无效"); } }