Question about Predicates

Posts   
 
    
teizela
User
Posts: 13
Joined: 24-Jul-2004
# Posted on: 22-May-2006 17:24:02   

Hi,

when filtering collections I use the following code (selfservicing) as described in the docs:


AEntityCollection colAEntity = new AEntityCollection();
IPredicateExpression filter = (AEntityFields.AField == aValue) & (AEntityFields.BField == bValue);
colAEntity.GetMulti(filter);

and it works fine. But if I have only one filter criterium this approach doesn't work and I have to use:


AEntityCollection colAEntity = new AEntityCollection();
IPredicateExpression filter = new PredicateExpression();
filter.Add(AEntityFields.AField == aValue);
colAEntity.GetMulti(filter);

Is this as designed or am I doing something wrong?

Thanks in advance Andreas

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 22-May-2006 17:27:04   

That's a limitation of the operator overloading scheme in .NET at the moment. Until Linq is released, we've to deal with what .NET offers, I'm afraid.

You can speed it up a bit by doing: IPredicateExpression filter = new PredicateExpression((AEntityFields.AField == aValue));

simple_smile

Frans Bouma | Lead developer LLBLGen Pro
teizela
User
Posts: 13
Joined: 24-Jul-2004
# Posted on: 22-May-2006 18:39:45   

Cool trick. Thanks alot.