views:

398

answers:

1

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?

+1  A: 

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;
vikasde
That is a great bit of information!
Andrew Siemer
Are you sure joins are not supported? I thought only group joins.
UpTheCreek