Sorting based on calculated value

Topics: Writing modules
Feb 11, 2013 at 7:49 PM
I am looking for some input/examples on how to code a ISortCriterionProvider that sorts based on a calculation done each query.

An example would be to be able to sort by the number of Tags in a TagsPartRecord (without actually storing the number of tags in the record).

Are there any existing modules that do something similar to this? Any tips/advice on how to do this?
Coordinator
Feb 11, 2013 at 10:13 PM
I don't think you can do it out of the box.

What you could do is have a TagsCountPart which would maintain the number of tags when attached to a type. Then you could easily expose it as a custom filter and use it in your projection queries.

To count tags you just need to create a handler for TagsPart, then scrutinize any change and update the count.