Consider this 3 classes
public class ClassA
{
public IList<ClassB> BList {get; private set;}
}
public class ClassB
{
public ClassC C {get; private set;}
}
public ClassC
{
//doesn't matter
}
I want to get all ClassA instances from the repository, that has at least one BList element containing a specific C instance, that i pass to the repository:
public IList<ClassA> GetAllAContainingC(ClassC parameterC)
i used Linq To Nhibernate to obtain this list:
var query = Session.Linq<ClassA>().Where(a => a.BList.Count(b => b.C.Equals(parameterC)) > 0);
return query.ToList();
The compiler accepts this. But when i run the test NHibernate throws this exception:
NHibernate.QueryException: could not resolve property: C of: ClassA
But the thing is, C is property of B, and in that lambda in the context where I call C, its being accessed from a B, (even the intelissense lists that property).
Can anyone explain me what i am doing wrong? Thank you