Hello all, after creating a sample web application POC using the
Entity Framework I am attempting to do the same with NH. I ran into
what is probably a very simple issue however I can't quite find the
solution. My web application is passing an Author object to my service
which then supposed to delete the author and all of its children
(Articles). I am not utilizing cascading delete so I am trying to nuke
those articles manually before I nuke the author, however I can't get
the author.Articles list to populate. In the below example
author.Articles is always null. I understand I must be missing
something regarding the disconnected nature of what I am attempting to
do here, but in Entity Framework I was able to simply attach my entity
to the ObjectContext (session in NH) and go from there as usual. I
recognize that I could simply query first for the Author instance
first, but the whole point is to avoid that query as I already have
that object being passed into the service.  When I put a break-point
on the author I realize that there is no proxy class associated with
author.Articles, how do I get that proxy class to appear?  Thank you.

public void DeleteAuthor(Author author)
        {
            using (ISession session = GetSession())
            {
                using (ITransaction tx = session.BeginTransaction())
                {
                    try
                    {
                        foreach (Article article in author.Articles)
                        {
                            session.Delete(article);
                        }

                        session.Delete(author);
                        session.Flush();
                        tx.Commit();
                    }
                    catch (HibernateException)
                    {
                        tx.Rollback();
                        throw;
                    }
                }
            }
        }

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to