case-insensitive search

Posts   
 
    
Rhywun avatar
Rhywun
User
Posts: 44
Joined: 05-Jan-2005
# Posted on: 17-Sep-2007 20:34:10   

I always allow the user to perform case-insensitive searches on my sites, and while I know how to do this in the generated code, I wonder if there's a more concise way. For example I started with this:

filter.AddWithOr(PersonFields.LastName % likeValue);

When I realized I needed to specify case-insensitivity, I wound up writing this:

predicate = new FieldLikePredicate(PersonFields.LastName, likeValue);
predicate.CaseSensitiveCollation = true;
filter.AddWithOr(predicate);

Ideally I'd like a way to specify case-insensitivity using the short form -- I think it would make my code more readable. Plus I filter on a lot of fields.

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 17-Sep-2007 21:24:45   

I think that your are already doing it the best way possible. By the way I think the correct line would be:

predicate = new FieldLikePredicate(PersonFields.LastName, likeValue.ToUpper());

becasue the CaseSensitiveCollation property, when set to true, would use the UPPER() function equivalent in your db.

Cheers,

Rhywun avatar
Rhywun
User
Posts: 44
Joined: 05-Jan-2005
# Posted on: 17-Sep-2007 22:10:36   

goose wrote:

I think that your are already doing it the best way possible.

OK. Perhaps I will request a feature in another section of the forum simple_smile Or maybe roll my own...

goose wrote:

By the way I think the correct line would be

Thanks--I remembered that after I watched it fail the first time simple_smile