NON Case-sensitive; in-memory filtering using Predicates

Posts   
 
    
JRR avatar
JRR
User
Posts: 125
Joined: 07-Dec-2005
# Posted on: 22-Jul-2006 00:04:55   

Hey Frans & others!

For starters, thanks for a great development tool! simple_smile

Ok, I am trying to filter an entitycollection in memory. I do not want these predicates to be case sensitive.

I was trying to this implement using "native language constructs."


        Dim filter As IPredicateExpression = ((LiveBlocksFields.StrProductId = lb.StrProductId.ToUpper) And _
        (LiveBlocksFields.Ready = lb.Ready.ToUpper) And (LiveBlocksFields.StrWarehouseId = lb.StrWarehouseId.ToUpper))

The above strategy was not allowing me to specify the CaseSensitiveCollation property of the FieldCompareValuePredicate.

After reading the manual more frowning , I have code that performs the filter NON Case-sensistive, but not as efficiently: cry


        filter = New PredicateExpression

        Dim ProdID As New FieldCompareValuePredicate
        ProdID = (PredicateFactory.CompareValue(LiveBlocksFieldIndex.ProductId,  ComparisonOperator.Equal, lb.StrProductId.ToUpper))
        ProdID.CaseSensitiveCollation = True

        Dim ready As New FieldCompareValuePredicate
        ready = (PredicateFactory.CompareValue(LiveBlocksFieldIndex.Ready, ComparisonOperator.Equal, lb.Ready.ToUpper))
        ready.CaseSensitiveCollation = True

        Dim Warehouse As New FieldCompareValuePredicate
        Warehouse = (PredicateFactory.CompareValue(LiveBlocksFieldIndex.WarehouseId, ComparisonOperator.Equal, lb.StrWarehouseId.ToUpper))
        Warehouse.CaseSensitiveCollation = True

        filter.Add(ProdID)
        filter.AddWithAnd(ready)
        filter.AddWithAnd(Warehouse)

Is there are better way than what I have settled for?

  • VB.net 2005
  • LLBLGen 2.0
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39616
Joined: 17-Aug-2003
# Posted on: 22-Jul-2006 09:50:46   

You could do:


Dim filter As IPredicateExpression = ((LiveBlocksFields.StrProductId = lb.StrProductId.ToUpper) And _
        (LiveBlocksFields.Ready = lb.Ready.ToUpper) And (LiveBlocksFields.StrWarehouseId = lb.StrWarehouseId.ToUpper))
For Each compareValuePredicate As FieldCompareValuePredicate in filter
    compareValuePredicate.CaseSensitiveCollation = True
Next

(ignore syntax errors for the vb code, I didn't know for sure For Each were to different tokens)

This works, as long as you're using fieldcomparevalue predicates only of course simple_smile

Frans Bouma | Lead developer LLBLGen Pro
JRR avatar
JRR
User
Posts: 125
Joined: 07-Dec-2005
# Posted on: 24-Jul-2006 19:52:09   

Thanks

er.. I should have seen that simple_smile