Use an IQueryable<Entitybase2> in FilterOn

Posts   
 
    
neilx
User
Posts: 267
Joined: 02-Nov-2007
# Posted on: 14-Oct-2011 11:08:31   

I have a complex bit of filtering to do on a prefetch path that I have extracted to an independent IQueryable called 'regIds'. I then try and use it in the FilterOn but get an error:

Here's the PrefetchPath:

   a=>
                   a.Prefetch<RegulationCountryRegionEntity>(
                     b=> b.RegulationCountryRegion).FilterOn(
                     c=> regIds.Contains(c.RegID))

The regIds IQueryable<string> is:

            regIds = (from a in MetaData.RegulationCountryRegion
                                                   where regsInHeading.Contains(a.RegID)
                                                   select a.RegID).Distinct();

Whilst the the IQueryable works just fine in where regIds.Contains(regId) constructs, when I use it in a FilterOn I get this error:

Exception Details: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryConstructionException: The Contains method on the type System.Linq.Queryable isn't convertable to an LLBLGen Pro construct.

I have tried it with an IQueryable<RegulationCountryRegionEntity> too but that gives the same error.

Is there something obvious I have done wrong?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Oct-2011 03:16:00   

First of all: What LLBLGen version and runtime library version are you using? (http://llblgen.com/tinyforum/Messages.aspx?ThreadID=14224) Make sure you are using the latest build.

Alsog, Is regIds in the scope of your query already? Is it a list or an IQueryable at the time you use it? Try to convert it to list first:

regIds = (from a in MetaData.RegulationCountryRegion
                                                 where regsInHeading.Contains(a.RegID)
                                                 select a.RegID).Distinct().ToList();

If still doesn't work, please post more info (see my link above). This include the complete query (i.e. post what exactly is 'a').

David Elizondo | LLBLGen Support Team