DbFunctionCalls don't work with "IN" operator

Posts   
 
    
Andy123456
User
Posts: 2
Joined: 04-Jun-2025
# Posted on: 04-Jun-2025 07:54:33   

Hello

I can pass DbFunctionCalls to <IEntityFieldCore>.Equal, but I haven't found a way to use DbFunctionCalls with the "IN" operator.

I would like to do the following which doesn't work because <IEntityFieldCore>.In doesn't accept IExpressions like <IEntityFieldCore>.Equal does.

var getSubordinatePersonIds = new DbFunctionCall("SELECT PersonId FROM GetSubordinatePersonIds({0})", [supervisorPersonId]);
predicateExpression.AddWithOr(PersonFields.PersonId.In(getSubordinatePersonIds));

Is there any other way to make DbFunctionCalls work with the "IN" operator?

I'm using LLBLGen Pro 5.7.0.

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39887
Joined: 17-Aug-2003
# Posted on: 04-Jun-2025 09:14:36   

That's indeed something that's not directly supported by a QuerySpec construct, so you have to build it using the low level API, as in, create a FieldCompareSetPredicate, where you pass in PersonFields.PersonId as the field and create a new field with queryFactory.Field() and set its Expression property to getSubordinatePersonIds, and use In as the Setoperator.

so something like:

predicateExpression.AddWithOr(new FieldCompareSetPredicate(PersonFields.PersonId, null, 
                    qf.Field("personIds").SetExpression(getSubordinatePersonIds), null, SetOperator.In, null));
Frans Bouma | Lead developer LLBLGen Pro
Andy123456
User
Posts: 2
Joined: 04-Jun-2025
# Posted on: 04-Jun-2025 14:16:33   

Thanks for the quick reply. That works well!