示例#1
0
        /// <summary>
        /// 删除帖子
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Response DeletePost(int id)
        {
            if (id == 0)
            {
                throw new ArgumentNullException(nameof(id));
            }
            var response = new Response();

            using (var tran = DbBase.GetTransaction())
            {
                //删除帖子
                var r1 = DbBase.Delete <Posts>(id);
                //删除评论
                var r2 = DbBase.DeleteMany <Comment>().Where(p => p.PostId == id).Execute();

                tran.Complete();
                if (IsUpdateSuccess(r1))
                {
                    response.IsSuccess = true;
                    response.Message   = "操作成功";
                    return(response);
                }
            }
            response.Message = "操作失败";
            return(response);
        }
示例#2
0
        /// <summary>
        /// 删除车辆信息
        /// </summary>
        /// <param name="plateNo"></param>
        /// <returns></returns>
        public static bool Delete(string plateNo)
        {
            DbBase <VehicleModel> db = new DbBase <VehicleModel>();

            db.Delete(p => p.PlateNo == plateNo);
            db.SaveChanges();

            return(true);
        }
示例#3
0
        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="expr"></param>
        /// <param name="operation"></param>
        /// <param name="value"></param>
        public virtual bool Delete(DapperExQuery <T> query, IDbTransaction transaction = null)
        {
            bool flag = false;

            using (DbBase DbContext = new DbBase(connectionName))
            {
                flag = DbContext.Delete <T>(query.GetSqlQuery(DbContext), transaction);
                DbContext.CloseConnection();
            }
            return(flag);
        }
示例#4
0
 public virtual bool Delete(DbBase dbs, SqlQuery sql = null)
 {
     return(dbs.Delete <T>(sql));
 }