samedi 27 juin 2015

NHibernate Query Collection is containing itself

I have used Fluent Nhibernate to create some simple mappings. In this mapping I have a bag and this bag is correctly auto mapped and everything is fine (just two tables with 1:n relationship).

However, when I do a Query with a Tolist after it (the bag is an IList in the class) the collection is always containing itself recursively and infinitive. So when I look what inside the object is after the Query it looks like this:

+collection
+row1
+row2

when I open up collection, it again contains:

+collection
+row1
+row2

and so on. I can open collection unlimited so the collection is containing itself.

What is the reason for this? The problem is: When I return this data as JSON, there is always a null where the collection is because I have set JSON to ignore any loops. But this is really a sad thing. I would like to fix this thing...

Thanks!! Best, Chris

Aucun commentaire:

Enregistrer un commentaire