Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have set Examine rightly and now I can use it get nodes. But I want to sort node by using multiple user fields, How to do it?
<IndexSet SetName="SimpleIndexSet" IndexPath="~/App_Data/SimpleIndexSet">
<IndexUserFields>
<add Name="Order" EnableSorting="true" type="Number" />
<add Name="PublishDate" EnableSorting="true" type="DateTime"/>
</IndexUserFields>
</IndexSet>
the Following is right:
var searchResults = Searcher.Search(query).OrderByDescending(x => x.Fields["Order"]);
After I change Order to PublishDate, It shows error. Why this happen?
I know I can use:
var searchResults = Searcher.Search(query).OrderByDescending(x => x.Order).OrderByDescending(x => x.PublishDate);
But now PublishDate can't be used. Why?
Not entirely sure what you are asking... but
will only order by publishdate... if you want to order by Order and then publishdate then this should work
var searchResults = Searcher.Search(query).OrderByDescending(x => x.Order).ThenByDescending(x => x.PublishDate);
or if you are having issues with actually using x.PublishDate then maybe this can be used?
.ThenByDescending(x => Convert.ToDateTime(x.GetPropertyValue("PublishDate"))
??
Thank you! I just wonder why PublishDate can't be used!!! I have added it into SimpleIndexSet.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to sort Examine result and sort it by multiple fields?
I have set Examine rightly and now I can use it get nodes. But I want to sort node by using multiple user fields, How to do it?
<IndexSet SetName="SimpleIndexSet" IndexPath="~/App_Data/SimpleIndexSet">
<IndexUserFields>
<add Name="Order" EnableSorting="true" type="Number" />
<add Name="PublishDate" EnableSorting="true" type="DateTime"/>
</IndexUserFields>
</IndexSet>
the Following is right:
var searchResults = Searcher.Search(query).OrderByDescending(x => x.Fields["Order"]);
After I change Order to PublishDate, It shows error. Why this happen?
I know I can use:
var searchResults = Searcher.Search(query).OrderByDescending(x => x.Order).OrderByDescending(x => x.PublishDate);
But now PublishDate can't be used. Why?
Not entirely sure what you are asking... but
var searchResults = Searcher.Search(query).OrderByDescending(x => x.Order).OrderByDescending(x => x.PublishDate);
will only order by publishdate... if you want to order by Order and then publishdate then this should work
var searchResults = Searcher.Search(query).OrderByDescending(x => x.Order).ThenByDescending(x => x.PublishDate);
or if you are having issues with actually using x.PublishDate then maybe this can be used?
.ThenByDescending(x => Convert.ToDateTime(x.GetPropertyValue("PublishDate"))
??
Thank you! I just wonder why PublishDate can't be used!!! I have added it into SimpleIndexSet.
is working on a reply...