v3 - adapter, call function in like predicate

Posts   
 
    
miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 22-Sep-2010 13:53:55   

Hi,

how can I achieve a following query:

where "content".to_lowercase("value") like "content".to_lowercase('%RAMbo%')

"content".to_lowercase is a custom db function "value" is a column name

I've tried to create a following Expression:

new EntityField2("dbValueCaseInsensitive", new DbFunctionCall("\"content\".to_lowercase", new object[] { FieldFields.Value })) 
% 
new EntityField2("searchedValueCaseInsensitive", new DbFunctionCall("\"content\".to_lowercase", new object[] { fieldValue }))

but compiler says that I Cannot use % operator on two EntityFields2 objects.

Best Regards, MiloszeS

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Sep-2010 15:11:47   

It seems to me you are trying to implement a case insensitive Like query, right?

You can use the FieldLikePredicate and set its CaseSensitiveCollation property to true. And then you will only have to pass the string pattern in upperCase too.

This should give the same results as your query, but it's just uses Upper Cases rather than Lower Cases.