开发者

FixUp-esque Collection for NHibernate?

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 a开发者_如何学JAVAny code though): "I wrote my own collection classes for NHibernate that will do the fixups for the relationships".

Thanks for any info!


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:

  • http://ayende.com/Blog/archive/2005/09/30/NHibernateOnNet20PartI.aspx
  • http://ayende.com/Blog/archive/2005/10/01/NHibernateOnNet20PartIII.aspx
  • http://ayende.com/Blog/archive/2005/10/01/NHibernateOnNet20PartIVTheSucess.aspx
  • http://ayende.com/Blog/archive/2005/10/07/BugFixInNHibernateGenerics.aspx
  • http://ayende.com/Blog/archive/2005/12/23/NHibernateGenericsEntityListUpdate.aspx

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜