Retrieving content and all related properties in Orchard CMS

Is there a good way to programmatically pull a list of content items from Orchard?

At the moment, I am doing this, which returns ContentPartRecord and Title, but this is not very pretty:

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 relevant documentation would be greatly appreciated, in this respect very little for Orchard.

+1
source share
1 answer

Avoid Containsat all costs. It will be terrible. Use the search module instead.

+1
source

All Articles