예제 #1
0
        private void RecursiveDelete(ArticleCategory parent)
        {
            if (parent.SubCategories != null)
            {
                var children = ArticleCategory
                               .Include(x => x.SubCategories)
                               .Include(x => x.Articles)
                               .Where(x => x.ParentId == parent.Id);

                foreach (var child in children)
                {
                    RecursiveDelete(child);
                }
            }

            foreach (var item in parent.Articles)
            {
                Article.Remove(item);
            }

            ArticleCategory.Remove(parent);
        }