I am using NHibernate with fluent mapping. I have the following scenario:
public class A
{
public virtual int ID{get; set;}
public virtual B BReference {get; set;}
public virtual string aProperty {get; set;}
}
public class B
{
public virtual int ID {get;set;}
public virtual string Name {get; set;}
}
public class MapA: Map<A>
{
Id(x=> x.ID);
Map (x=> x.aProperty);
References(x => x.BReference);
}
public class MapB : Map<B>
{
Id(x=>x.ID);
Map(x=>x.Name);
}
What i want to do is to filter A objects on the property A.BReference.Name. I am using the queryover to do my queries:
public object GetResult(ISession session)
{
var result = session.QueryOver<A>.Where(a=> a.BReference.Name=="Value").List();
return result;
}
Currently NHibernate is throwing an exception Could not resolve property BReference.Name of: A.
Is there some way to overcome this propblem? I can't change the queryover pattern now because we have dependence on it. Thanks for your help.