Search in multiple columns

Posts   
 
    
kristianl
User
Posts: 1
Joined: 23-Jun-2008
# Posted on: 18-Jul-2008 09:40:24   

Hello!

I have a table with several textfields. I want to make a search for posts where ANY of the textfields match a given text. Is there a simple way to do this?

Walaa avatar
Walaa
Support Team
Posts: 14951
Joined: 21-Aug-2005
# Posted on: 18-Jul-2008 11:08:07   

That's supported since v2.5, you can specify multiple fields in the FieldCompareFullTextSearch predicate. (for sqlserver2005 and up).

public FieldFullTextSearchPredicate(IList entityFields, FullTextSearchOperator operatorToUse, string pattern) 

Example:

PredicateExpression.Add(new FieldFullTextSearchPredicate(
    new IEntityField2[] { CustomerFields.CompanyName, CustomerFields.ContactName},
    FullTextSearchOperator.Contains, "XYZ"));

You can also use OR-ed FieldLikePredicate expressions.