Ipredicate not working as expected

Posts   
 
    
deepunair
User
Posts: 12
Joined: 24-Feb-2022
# Posted on: 03-Mar-2022 16:53:01   

Below is my existing code which using the LLBLGen version 1.x

bk.PredicateExpression.Add(PredicateFactory.CompareValue(UserFieldIndex.Login, ComparisonOperator.Equal, SearchCollection["UserId"]));

So according to the documentaion , we replaced the PredicateFactory with Ipredicate as

IPredicate predicate = UserFieldIndex.UserId.Equal(Convert.ToInt32(SearchCollection["UserId"]));

But we are not getting the exact result, getting error at UserFieldIndex.UserId saying that 'UserFieldIndex' doesn't contain a definition for Equal. Did I miss anything.? Could you please help on this

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 04-Mar-2022 10:07:53   

Use:

IPredicate predicate = UserFields.UserId.Equal(Convert.ToInt32(SearchCollection["UserId"]));

The index enum is for indexing inside a Fields object, you need to specify the field object itself. This wasn't present in v1, these field objects are generated and are introduced around v3.

Frans Bouma | Lead developer LLBLGen Pro
deepunair
User
Posts: 12
Joined: 24-Feb-2022
# Posted on: 04-Mar-2022 12:23:06   

Otis wrote:

Use:

IPredicate predicate = UserFields.UserId.Equal(Convert.ToInt32(SearchCollection["UserId"]));

The index enum is for indexing inside a Fields object, you need to specify the field object itself. This wasn't present in v1, these field objects are generated and are introduced around v3.

Thanks for the update. Now its working fine