Linq to nhibernate - Having where clause problems
-
12-09-2019 - |
Question
I am using linq-to-nhibernate with the following query:
ISession session = GetSession();
var query = from storeZoneStyles in session.Linq<StoreZoneStyle>()
from storeZones in session.Linq<StoreZone>()
where storeZoneStyles.StoreZoneId == storeZones.StoreZoneId && storeZones.StoreCode == storeCode
select storeZoneStyles;
With this query, I only want to get all storeZoneStyles that belong to a storecode. Now when I run this I get the following run-time exception:
Unable to cast object of type 'System.Linq.Expressions.ConstantExpression' to type 'System.Linq.Expressions.LambdaExpression'.
Can somebody help me out please?
Solution
I had to use this query instead, because joins are not supported in L2N
var query = from storeZoneStyles in session.Linq<StoreZoneStyle>()
where storeZoneStyles.Zone.StoreCode == storeCode
select storeZoneStyles;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow