以编程方式从废纸篓中删除N2 CMS节点

时间:2012-12-15 21:22:03

标签: c# n2cms

在N2 CMS中,有没有办法以编程方式从垃圾箱中删除节点?

1 个答案:

答案 0 :(得分:0)

我明白了。在此示例中,TargetDetailModel类型的模型将从N2 CMS垃圾箱中永久删除。

var trash = new ItemList<TrashContainerItem>(N2.Find.RootItem.Children, new TypeFilter(typeof(TrashContainerItem))).FirstOrDefault();
if (trash != null)
{
  var detailToPermDelete = new ItemList<TargetDetailModel>(trash.Children, new TypeFilter(typeof(TargetDetailModel)));
  for (int permDeleteCount = 0; permDeleteCount < detailToPermDelete.Count; permDeleteCount++)
  {                            
    N2.Context.Current.Persister.Delete(detailToPermDelete.ElementAt(permDeleteCount));
  }
}