Query filter on (property in related record of a record (sub record)

Topics: General, Writing modules
Oct 14, 2012 at 9:44 AM

I've have the following query: 

      .Where<ClubPartRecord>(c=> c.CityPartRecord.RegionPartRecord == null)

So "ClubPartRecord" has a related record "CityPartRecord" and "CityPartRecord" has a related record "RegionPartRecord". I get the following error with this query:

could not resolve property: CityPartRecord.RegionPartRecord of: Users.Models.Records.ClubPartRecord

As far I can see the normal query method can't query sub properties/records so it's returning this error. Queryhints doesn't solve this either. Could this be done using a normal Query or do I have to use a HQL query? Or is this not even possible with HQL and do I have to use a plain SQL query. Thanks!


Oct 14, 2012 at 6:40 PM

I think you can use a Join for that.

Oct 14, 2012 at 9:38 PM

prob something like this...

.Where(c=> c.RegionPartRecord == null)


Oct 15, 2012 at 5:23 PM

Nope already tried that but always same problem. Now i've done this using 2 separate queries but this is far from optimal.

Jan 19, 2013 at 11:50 AM

Perhaps try to query by Id instead of navigation properties, applying joins as needed.