Retrieving content and all associated properties in Orchard CMS

邮差的信 提交于 2019-12-11 08:14:58

问题


Is there a good way of programmatically pulling back a list of Content Items from Orchard?

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()
            });
    }

Any pointers to related documentation would be greatly appreciated, there's very little in this regard for Orchard.


回答1:


Avoid Contains at all costs. It will perform horribly. Instead, leverage the Search module.



来源:https://stackoverflow.com/questions/16704132/retrieving-content-and-all-associated-properties-in-orchard-cms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!