I have two entities, "List" and "ListItem". My "List" entity have a
parent property: "public virtual List listParent {get;set;}". My
queries works when "listParent" is null, but when I set a parent for
example, "Countries" parent list, and the child list is "States". When
I do a query on "ListItem" to pulls items for "States" I got an error:
"A circular reference was detected while serializing an object of type
JsonResult".
What I found during debugging causing the error:
I did a query on the "ListItem" to pull all the items, but I want only
from the "States", so I need to tell NHibernate to do a "WHERE clause"
with the "listId" column. The nature of NHibernate, it queries the
"List" table for "States" and continue to query into the "listParent",
which I don't need.
1. How do I limit the query to just the "listId" column in the "List"
table??? Because, the "List" table has a "listParent" column, which
NHibernate continue to query into.
2. I don't know why NHibernate need to include the "List" table to do
a "WHERE clause" on the "listId", even though the "ListItem" table
already has a "listId" column???
Code Snippet:
/// <summary>Get items.</summary>
public static IList<Models.ListItem> GetItems(Guid categoryId) {
return Models.ListItem.FindAll(new ICriterion[] {
Restrictions.And(
Restrictions.Eq("itemList.listId", categoryId),
Restrictions.Eq("itemIsDeleted", false)
)
});
}
Specs:
NHibernate 2.1.0GA
Castle ActiveRecord 2.0
Thank you for your help,
William Chang
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---