• 00
  • :
  • 00
  • :
  • 00

后台删除正确写法

public GZAPIResult FormDelete(string rowID)
        {
            try
            {
                //删除actions
                base_moduleForm model = new base_moduleForm();
                model.rowID = rowID;
                entities.Entry(model).State = System.Data.EntityState.Deleted;
                entities.SaveChanges();
                sysAuthorizeBiz.refreshCache(sysAuthorizeBiz.CacheFlag.base_moduleFormActions | sysAuthorizeBiz.CacheFlag.base_moduleFormAuthorize | sysAuthorizeBiz.CacheFlag.base_moduleFormAuthorizeAction);
            }
            catch (Exception ex)
            {
                if (true == ex.IsSqlReferenceConstraintException())
                {
                    return GZAPIBadRequest("删除失败,存在关联数据", EnumResponseCode.errSqlReferenceConstraintException, SqlOOT.DELETE);
                }
                else
                    throw ex;
            }

            return GZAPISuccess();
        }
fdsf
posted @ 2018-04-09 10:31  Garson_Zhang  阅读(413)  评论(0编辑  收藏  举报