I’m working on a model that uses NHibernate for database interaction. There is a class called PostCategory that contains a collection of Post that are lazy-loaded and i’m using NewtonSoft.Json API for serializing the objects into JSON.
When I try to serialize the collection of PostCategories they throw error beacause of the lazy-loaded posts inside them. Currently I’ve creating an anonymous query to select only the particular properties from the PostCategory and serializing that query into JSON.
Is there any better solution to overcome this problem?
Vijaya Anand
I would suggest you to serialize an anonymous object as explained by ayende here.