views:

50

answers:

1

Hello,

I'm working on getting started with NHibernate on a large scale project (have worked with it in small-scale before), and am digging into the issue of managing relationships... specifically, what best practices are out there for doing so?

Example: The classic: you have a Blog and Comments, the blog points to (0-n) comments, each comment in the collection points back to the blog {0,1}.

Out-of-the box it seems it's up to you to not shoot yourself in the foot (by mis-matching the child object relationships, for example). We're hoping for a better solution to build upon...

One option I've found is making the collection private and providing accessor/mutation methods for it. The fixup can then be done in those methods.

But I'm wondering if a better solution is out there-- something like a "FixupCollection" (used in the Entity Framework's POCO template)

Also, Ayende mentions a FixupCollection of his own (ADO.Net Entity Framework Round II post, can't find any code though): "I wrote my own collection classes for NHibernate that will do the fixups for the relationships".

Thanks for any info!

+1  A: 

That's a very old post (2006) and I think Ayende's talking about EntitySet / EntityRef / EntityList which he wrote back when .Net 2.0 was new (2005). Here are some posts about it:

I don't think this is maintained anymore, here's the latest code I was able to find.

Mauricio Scheffer
Great! I did look for that but failed to find it, good call on the svn repository, thanks! :)That answers part of the question-but I'm still wondering what most people out there do for dealing with this issue... if the answer is "by hand" that's cool too
Bobby
Personally yes I do it by hand.
Mauricio Scheffer