I have a IQueryable<T>
object as search results object.
I apply the filtering and sorting on this search object.
Before I call the GetResults()
, I want to order the results based on one of the field's (Fieldname - Priority
) value. So for all the items in the IQueryable<T>
object, I want to order them desc by Priority field, so all the items which has a value for that field stay at the top and the rest are at the bottom.
I have the fieldmap
entry for Priority field.
search.OrderByDescending(i => !string.IsNullOrEmpty(i.GetItem().GetFieldValue("Priority")))
The above command doesn't work. Apparently, I can't use Sitecore extension methods with IQueryable?
If I convert search.ToList()
. Do the ordering and then convert it back to AsQueryable()
, I get the following error:
There is no method 'GetResults' on type 'Sitecore.ContentSearch.Linq.QueryableExtensions'
that matches the specified arguments
Is there a neat and quick way to get around this?
Cheers
I apply the filtering and sorting on this search object
- Are you sorting by multiple fields? e.g. Title and Priority? – jammykam