views:

96

answers:

1
Class A
{
Guid ID{get;}
ISet<B> ClassBs {get;}
}


repository
public IList<B> GetAsBs(A a)
{
ICriteria ACriteria = Session.CreateCriteria(typeof(A));
ICriteria BCriteria = ACriteria.CreateCriteria("ClassBs");
A.Add(Restrictions.Eq("ID", a.ID));
return BCriteria.List<B>();
}

I can accomplish this in HQL np but want to use criteria i am getting an error that it is trying to return A not B

any help would be great

A: 

i just went HQL for anyone that is interested

            public IList<B> GetAsBs(A aClass)
            {
            string hql = @"
                SELECT B
                FROM    A a
                JOIN     a.ClassBs b
                WHERE  A.ID = :ID
            ";
            IQuery query = Session.CreateQuery(hql);
            query.SetParameter("ID", aClass.ID);

            return query.List<B>();
}
Brandon Grossutti