本文介绍了检索Orchard CMS中的内容和所有相关属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有很好的方法以编程方式从果园中拉回内容项列表?
Is there a good way of programmatically pulling back a list of Content Items from Orchard?
目前我正在执行此操作,该操作返回ContentPartRecord和Title,但无论如何它都不是很漂亮:
At the moment I'm doing this, which returns a ContentPartRecord and the Title, but it's not pretty by any means:
public IEnumerable<LookupViewModel> Lookup(string searchText)
{
var items = _contentManager
.Query<MyItemPart, MyItemPartRecord>()
.Join<TitlePartRecord>()
.Where(x => x.Title.Contains(searchText))
.OrderBy(x => x.Title)
.List();
return items
.Select(x => new LookupViewModel()
{
Text = x.Name,
Value = x.Id.ToString()
});
}
任何指向相关文档的指针将不胜感激,在这方面,对于Orchard来说几乎没有.
Any pointers to related documentation would be greatly appreciated, there's very little in this regard for Orchard.
推荐答案
不惜一切代价避免使用Contains
.它将表现可怕.而是利用搜索模块.
Avoid Contains
at all costs. It will perform horribly. Instead, leverage the Search module.
这篇关于检索Orchard CMS中的内容和所有相关属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!