If you want to query you’re database with LLBLGen, by filtering entities using the TQL Like operator you should use the FieldLikePredicate

See LLGLGen v2.6 documentation: http://www.llblgen.com/documentation/2.6/hh_start.htm
Specific part: http://www.llblgen.com/documentation/2.6/Using%20the%20generated%20code/Adapter/Filtering%20and%20Sorting/gencode_filteringpredicateclasses_adapter.htm#FieldLikePredicate

FieldLikePredicate

Description
compares the entity field specified with the pattern specified, using the LIKE operator. The pattern should contain the wildcard, which is ‘%’ (also for MS Access). FieldLikePredicate performs a LIKE compare using the case sensitivity setting of the database system the query is executed on: the SQL generated does not contain any collation information nor any case insensitive setting if the database is using case sensitive comparison operations by default (Oracle, some SqlServer installations). You can perform case insensitive compares however, if the database is case sensitive, by setting the CaseSensitiveCollation property to true prior to passing the predicate to a fetch method like FetchEntityCollection(). This will perform the UPPERCASE variant of the field with the pattern specified.Please note that if you’ve set CaseSensitiveCollaction to true, you’ve to specify your pattern in uppercase as well.

SQL equivalent examples
Field LIKE ‘%bla’
Field LIKE ‘bla%’

Operators
none.

Example
This example creates a predicate which compares Customer.CompanyName to the pattern "Solution%".

  • C#
  • VB.NET
// 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#.

Can be used for in-memory filtering

Yes. When used in in-memory filters, the pattern can either be a normal LIKE statement pattern with ‘%’ wildcards, or it can be a full regular expression. If the pattern is a regular expression, be sure to set the property PatternIsRegEx to true. See also the LLBLGen Pro reference manual on more detailed information about the properties of the FieldLikePredicate

2 Comments

  1. Hi, Can I perform a Like with the value of another field merged in the pattern?
    For example I can’t create the next predicate expression:
    var code = Entity1Fields.Code;
    orderCode.ExpressionToApply = new Expression(new Expression(“someprefix_”, ExOp.Add, Entity1Fields.Code), ExOp.Add, “%”);
    var compareCodesExpression = new PredicateExpression(Entity2Fields.CompoundCode % orderCode);

    Frans Harinck

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.