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