Hi Craig, There is my article about how to persist tree-like structures in NHibernate http://alexzaytsev.me/2013/03/04/nhibernate-how-to-persist-tree-like-structures/ hope, that this will help.
Best Regards, Alexander 2014-06-17 5:02 GMT+12:00 Craig Gambino <[email protected]>: > After playing around for quite some time, I have the following working, > it's close enough to what I believe is acceptable, but I still think there > may be some improvement: > > public Forum LoadById(int id) > { > >> var forum = session.CreateCriteria<Forum>() >> .SetFetchMode("topics", FetchMode.Join) >> .Add(Restrictions.Eq("Id",id)) >> .FutureValue<Forum>(); >> >> var topics = session.CreateCriteria<Topic>() >> .SetFetchMode("posts", FetchMode.Join) >> .Add(Restrictions.Eq("Forum.Id", id)) >> .Future<Topic>(); >> >> var posts = session.CreateCriteria<Post>() >> .SetFetchMode("User", FetchMode.Eager) >> .SetFetchMode("children", FetchMode.Join) >> .Add(Restrictions.Eq("Forum.Id",id)) >> .Future<Post>(); >> >> return forum.Value; >> > } > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/nhusers. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
