How to sort by a number field?

Bertvan

When using the new Search API (ContentSearchManager.GetIndex...), how can we sort the result by a numeric field. When using default .OrderBy(), then the field is sorted by the string representation of these numbers.

This means that the order is like:

1, 10, 11, 2, 3, 4, 5... 

How can we instruct SiteCore to sort this field as a number?

I have found a answer on how to do this in 6.5, but we are using 7.

user459491

you need to have mappingItem to be something like :

public class MappingItem 
{ 
 [IndexField("orderingnumberIndex")] 
 int OrderingNumber {get; set;} 
} 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related