我的文档类型为“info”我也有一些自定义属性。
infoTitle infoSummary infoBody
我想检索文档类型“info”的所有文档并输出数据。
谢谢
答案 0 :(得分:13)
这个简单的剃刀宏可以达到你想要的效果:
@{
// Get root node:
var root = Model.AncestorOrSelf();
// Get all descendants, filter by type:
var nodes = root.Descendants("info");
// Loop through the filtered nodes, displaying the properties:
<ul>
@foreach (var node in nodes)
{
<li>
<h2>@node.infoTitle</h2>
<div>@node.infoSummary</div>
<div>@node.infoBody</div>
</li>
}
</ul>
}