Odd Problem With FieldLike Operator Overloading

Posts   
 
    
psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 26-Jun-2007 16:46:32   

It's not a big deal, since there is an obvious workaround, but why doesn't this work?


Bucket.PredicateExpression.Add(ProductFields.ProductId % "%" + Param.ProductId + "%");

(Param.ProductId is a string BTW)

Error 2 Argument '1': cannot convert from 'string' to 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicate'

Thanks,

Phil

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 26-Jun-2007 16:50:56   

Hello,

could you try to aggregate your pattern before :


string ParamId ="%" + Param.ProductId + "%";
Bucket.PredicateExpression.Add(ProductFields.ProductId % ParamId);

psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 26-Jun-2007 16:55:09   

jbb wrote:

Hello,

could you try to aggregate your pattern before :


string ParamId ="%" + Param.ProductId + "%";
Bucket.PredicateExpression.Add(ProductFields.ProductId % ParamId);

Yep, that's what I meant by there being a workaround. I'm just curious why it doesn't work.

Thanks,

Phil

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 26-Jun-2007 16:57:29   

During the compilation, it parse the first expression

ProductFields.ProductId % "%" 

And after he try to append the string :

+ Param.ProductId + "%";

There is no priority for it. So the last operation is a concatenation of string so it should return a string(that is not a predicate).

psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 26-Jun-2007 17:01:21   

jbb wrote:

During the compilation, it parse the first expression

ProductFields.ProductId % "%" 

And after he try to append the string :

+ Param.ProductId + "%";

There is no priority for it. So the last operation is a concatenation of string so it should return a string(that is not a predicate).

I guess it comes down to me not knowing much about operator overloading. simple_smile

Thanks for your (lightning fast!) responses.

Phil