Filtering on a partial text string (Looking for a contains ComparisonOperator)

Posts   
 
    
JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 11-Oct-2006 15:49:38   

I've done a few searches and tried a few other options but I've not got this to work. We're migrating a VB.NET 2003 project using LLBLGen Pro 1.0.2005 (I think) to VB.NET 2005 with LLBLGen Pro 2.0. We're also going from Self Servicing with one database to Adapter with two databases as we need to access both at once for enhancements.

We had the following code before which filtered the list of customers based on a substring:

Dim filter As IPredicateExpression = New PredicateExpression(PredicateFactory.Like(CustomerFieldIndex.Name, Me.txtAccountName.Text & "%"))

This code doesn't work directly as PredicateFactory is not declared. I have tried variations of: filter.Add(New FieldCompareValuePredicate(CustomerFields.Name, Nothing, ComparisonOperator.Equal, txtAccountName.Text)) but I can't get that to do a substring search - it's fine if you put the full customer name in...

I've tried things like: filter.Add(New FieldFullTextSearchPredicate(CustomerFields.Name, Nothing, FullTextSearchOperator.Contains, txtAccountName.Text)) But that complains that it's not full-text indexed and I don't want to have to change the database when this was possible before - there must be a way!

Thanks for your help,

James

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 11-Oct-2006 16:04:01   

The following was copied from the LLBLGen Pro manual:

// C# filter.Add(new FieldLikePredicate(CustomerFields.CompanyName, null, "Solution%"));

// Which is equal to: filter.Add(CustomerFields.CompanyName % "Solution%"); ' VB.NET filter.Add(New FieldLikePredicate(CustomerFields.CompanyName, Nothing, "Solution%"))

' Which is equal to: (VB.NET 2005) filter.Add(CustomerFields.CompanyName Mod "Solution%") Note, that the operator syntaxis is a little odd in VB.NET, due to the fact that there isn't an ability to add new operators to VB.NET/C#.

JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 11-Oct-2006 16:11:18   

Walaa wrote:

The following was copied from the LLBLGen Pro manual:

I did look there too! (Obviously not in the right places though!)

Thanks for your help, spot on.