I have a relatively simple application where my main aggregate chain
is: Category -> Forum -> Thread -> Reply.
My aggregate root repository is CategoryRepository natually.
I have AllDeleteOrphan set in my HasManyConvention so I can perform
deletes like the following.
category.RemoveForum(forum);
categoryRepository.Update(category);
Without it, all that happens is the foreign key get's nulled out, but
the record remains. With it set, it works like it should. However, it
introduces a problem in another action where I need to move a forum to
another category. This code will demonstrate.
if (currentCategory != destinationCategory)
{
// this seems to be needed so that the cache doesn't show the forum in
both categories
currentCategory.RemoveForum(forum);
// THIS LINE CAUSES THE ERROR. by the time it completes, the forum is
an orphan and is deleted.
categoryRepository.Update(currentCategory);
// now add it to the destination
destinationCategory.AddForum(forum);
// and save it
categoryRepository.Update(destinationCategory);
}
So the question is: what is the proper way to perform this operation?
--
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.