I have a tree structure in a database I am accessing through AR. My
goal is a function to walk the tree. I want to put this in a
stateless session because the tree can be very large and I don't want
to spend the resources on the first level cache if it is not
necissary.
But I can't seem to get the list of children to work properly in the
stateless session.
This is what I have so far:
void WalkTree(Model root, Action<Model> work) {
using (new StatelessSessionScope()) {
rWalkTree(root, work);
}
}
void rWalkTree(Model current, Action<Model> work) {
work(current);
foreach(Model child in Model.FindAllByProperty("Parent", current))
{
rWalkTree(child);
}
}
This works fine the first time through the foreach, but errors out
when run on the first child. I assume it worked the first time
because current was root which is instantiated outside of the
stateless session scope.
When it errors, it throws the an exception with the inner exception is
"could not execute query..." and it's inner exception is "possible non-
threadsafe access to the session", which seems odd (it is all on one
thread).
I have tried a Detached Query and a SQL Query as well. Both of which
causes the same error, the first time through the foreach.
All of these methods work fine on a standard session scope.
Am I doing something wrong, or is there a better way to do this?
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" 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/castle-project-users?hl=en.