A first chance exception of type
'System.Collections.Generic.KeyNotFoundException' occurred in
mscorlib.dll
A first chance exception of type 'NHibernate.QueryException' occurred
in NHibernate.dll

When my code hits this line:
criteria.GetExecutableCriteria(session).List()

The query brings back correct results however.  It generates the
exception pair for each sub query.

public static DetachedCriteria CommonPropertyCounts()
        {
            var criteria = DetachedCriteria.For<T>("this");

            DetachedCriteria subTag =
DetachedCriteria.For<Entities.TaggedEntity>("sub")
                .SetProjection(Projections.Count("Id"))
                .Add(Restrictions.EqProperty("sub.MajorEntity.Id",
"this.Id"));

            DetachedCriteria subNote =
DetachedCriteria.For<Entities.Note>("sub3")
                .SetProjection(Projections.Count("Id"))
                .Add(Restrictions.EqProperty("sub3.MajorEntity.Id",
"this.Id"));

            DetachedCriteria subAtt =
DetachedCriteria.For<Entities.Attachment>("sub4")
                .SetProjection(Projections.Count("Id"))
                .Add(Restrictions.EqProperty("sub4.MajorEntity.Id",
"this.Id"));

            criteria.SetProjection(Projections.ProjectionList()
                                   .Add(Projections.Property("this.Id"))
                                   .Add(Projections.Property("this.CreatedOn"))
                                   .Add(Projections.SubQuery(subTag))
                                   .Add(Projections.SubQuery(subPTag))
                                   .Add(Projections.SubQuery(subNote))
                                   .Add(Projections.SubQuery(subAtt))

                );

            return criteria;
        }

I'm not sure how to go about debugging this as it doesn't crash the
software.

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