一个Session
foreach (var item in favoriteId) { if (!string.IsNullOrEmpty(item)) { var favorite = _session.Get<Favorite>(Guid.Parse(item)); if (favorite != null) { // 删除资源 var favoriteList = _session.CreateCriteria<Favorite>().Add(Restrictions.Eq("ResId", favorite.ResId)).List(); if (favoriteList != null && favoriteList.Count <= 1) { _session.Delete(new FavoriteResourceInfo { ResId = favorite.ResId }); } // 删除关联 var favoriteLabelList = _session.CreateCriteria<FavoriteLabel>().Add(Restrictions.Eq("FavoriteId", Guid.Parse(item))).List<FavoriteLabel>(); //relationResponse.GetRelationByFavoriteId(Guid.Parse(item)); if (favoriteLabelList != null && favoriteLabelList.Count > 0) foreach (var favoriteLabel in favoriteLabelList) { _session.Delete(favoriteLabel); } // 删除收藏 _session.Delete(favorite); } }
时间: 2024-10-06 19:46:45