I have two entities: Client, and AccountPlan, that have a 1 to 0..1 relationship. I would like to fetch my Clients, ordered first by Clients that have an AccountPlan, and then by Clients that do not. When I try the following Linq to Nhibernate query:
return NHibernateSession.Current.Query<Client>()
.Where(x => x.SalesRepId == id)
.OrderBy(x => x.AccountPlan == null);
I get a QuerySyntaxException with the following message:
{“Exception of type ‘Antlr.Runtime.NoViableAltException’ was thrown.
[.OrderBy(.Where(NHibernate.Linq.NhQueryable`1[FIS.AccountManagement.Core.Domain.Client],
Quote((x, ) => (Equal(x.SalesRepId, p1))), ), Quote((x, ) =>
(Equal(x.AccountPlan, ))), )]”}
Here’s the mapping relationship between the two entities, if that’s important:
public ClientMap()
{
HasOne(x => x.AccountPlan).PropertyRef(r => r.Client);
}
public AccountPlanMap()
{
DynamicInsert();
References(x => x.Client, "EntityID");
}
Does anyone know of a query from one of NHibernate’s myriad APIs that will accomplish what I want? Thanks in advance.
two queries in one roundtrip concated together