后台删除正确写法

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
慎于行,敏于思!GGGGGG
原文地址:https://www.cnblogs.com/GarsonZhang/p/8757928.html