-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ISession.Filter broken with Ayende's GenericAccessor...
PostPosted: Wed Jan 18, 2006 11:21 pm 
Beginner
Beginner

Joined: Thu Dec 08, 2005 6:49 pm
Posts: 49
After converting all my collections from ISet to ICollection<T> based on the article & code at http://www.ayende.com/projects/nhibernate-query-analyzer/generics.aspx, I now get the error "the collection was unreferenced" when I call ISession.Filter on it.

Having a closer look, it would appear that this is because the reference is a wrapper, not an ISet itself. The following code should illustrate my problem:

Code:
using (ISession session = _Factory.OpenSession())
{
   foreach (Blog blog in session.CreateCriteria(typeof(Blog)).List())
   {
      foreach (Paddock paddock in session.Filter(blog.Posts, "where this.Author = 'nathan'"))
      {
         //this DOESN'T work
      }

      object postSet = blog.Posts.GetType().GetField("_set", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(blog.Posts);

      foreach (Paddock paddock in session.Filter(postSet, "where this.Author = 'nathan'"))
      {
         //this DOES work
      }
   }
}


Can anybody think of a clean workaround (Ayende Rahien: perhaps a unti test could be written to cover this scenario?).


Nato


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.