I have a linq query with a join that works fine against two generic
lists, but gives the exception above when run against nHibernate:

        public List<Message> GetInternalMessagesForUser(User user) {
            return (from conversation in Items
                    join message in Messages on conversation equals
message.Conversation
                    where message.Source != user &&
                    !message.IsDeleted &&
                    conversation.Members.Contains(user)
                    select message).ToList();
        }

  Attempting to work around it gave me quite a few exceptions that I
wasn't expecting.  My final workaround became the following queries:

            IQueryable<Conversation> q7 = from conversation in Items
                                     where
conversation.Members.Contains(user) && conversation.TypeString ==
"Internal"
                                     select conversation;
            IQueryable<Message> q8 = from conversation in q7
                                     from message in
conversation.Messages
                                     select message;
            List<Message> l8 = q8.ToList();
            IQueryable<Message> q9 = from message in l8.AsQueryable()
                                     where message.Source != user && !
message.IsDeleted
                                     select message;
            return q9.ToList();

So my question is "What is the appropriate way to join two related
tables in nHibernate?"  My workaround forces two calls to the db,
instead of one, as well as three queries because join is not
implemented.

A little further explanation on the data structure:
A conversation has a many-to-many relationship with user and a one-to-
many relationship with message.  The query is trying to find all
message belonging to a user (with a few specifications that don't
matter to this post).

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