Get number of associated items

Hi All,

I am basically building a blog, so i started with the template. I have added a Categories content type and have added a field to the post content type to associate them with the reference field option. So i can now see the Categories in the blog posts (in the JSON result).

Is there a way i can get the categories with the count of the number of posts that are associated without doing some crazy loops in c# and looping over the categories, then getting the pages where the category contain the category name?

Thanks for the help in advance


No, sorry…you can only denormalize some data with an nighly job or so.

ok makes sense, so trying this a different way,

I have tried to de-serialise my categories list inside the blog post like this (so i can use linq to query they data)

public List PostCategories { get; set; }

like in the example here:

i am getting the following error:

Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type ‘System.Collections.Generic.List`1[Models.Blog.Category]’ because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.

To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path ‘items[0]’, line 1, position 1779.

any ideas why it cant de-serialise the object?