c# 深度遍历节点并删除

2021-06-22 10:06

阅读:511

标签:task   name   node   list   深度   await   parent   turn   returns   

 1         public async Task DeleteModule(EntityDto input)
 2         {
 3             var id = input.Id;
 4             var children = await FindChildrenAsync(id);
 5 
 6             await DeleteAsync(children);
 7             
 8             await _repository.DeleteAsync(id);
 9         }
10         /// 
11         /// 删除操作
12         /// 
13         /// 
14         /// 
15         public async Task DeleteAsync(List children)
16         {
17             foreach (var child in children)
18             {
19                 var node = await FindChildrenAsync(child.Id);
20                 if (node.Count > 0)
21                     await DeleteAsync(node);
22                 await _repository.DeleteAsync(child);
23             }
24             
25         }
26         /// 
27         /// 查找子节点
28         /// 
29         /// 
30         /// 
31         public async Task> FindChildrenAsync(int? parentId)
32         {
33             return await _repository.GetAllListAsync(p => p.ParentId == parentId);
34         }

 

c# 深度遍历节点并删除

标签:task   name   node   list   深度   await   parent   turn   returns   

原文地址:https://www.cnblogs.com/cxyzhangjie/p/10214571.html


评论


亲,登录后才可以留言!