Hi, I have create a CTE (Common Table Expression) function in SQL to
populate in one shot a Tree of items.
The item is a recursive one like:
public class Item
{
public Item Parent { get; set;}
public List<Item> Children { get; set; }
}
I use the mapping with <many-to-one> and <bag ... one-to-many>.
Now, the first issue I have is that when I execute the SP it returns
me a "filtered" full tree that I map in this way:
ISession session =
this.unitOfWork.GetSession<ISession>();
IQuery query = session.GetNamedQuery("FetchTree");
query.SetString("criteria", string.Format("%{0}%",
searchViewModel.Criteria));
var result = query.SetResultTransformer(new
DistinctRootEntityResultTransformer()).List<Item>();
Now, for every Item, NHibernate still goes into the DB to fetch the
corresponding collection of children, which is wrong because it
shouldn't go anymore to the DB, as it is already "fetched"
everything ... How can I block this behavior?
The second issue is that even if I am using the Distinct transformer,
sometimes NHB does not aggregate the result so I get a list of:
1 - Parent item
1 - Child Item
1 - Child Item
but sometimes it returns the correct result
1 - Parent Item
1 - Child Item
...
--
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.