Bitmasking filtering in a predicate expression?

Posts   
 
    
jsaylor
User
Posts: 37
Joined: 20-Sep-2004
# Posted on: 07-May-2009 23:24:05   

I am using LL2.6

I can do bitmask filtering when fetching using the FieldCompareExpressionPredicate but I don't see a way to do it in-memory with a PredicateExpression since there is no similar ComparisonOperator for a predEx like ExOp.Bit* for Expressions.

Is that true or am I missing something?

Hmm, if it is - would it even be possible to fab my own PredicateExpression/Operator to do this?

Much appreciation in advance! Cheers, Jeff

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-May-2009 03:14:47   

Hi Jeff,

You could perform a FindMatches on your in-memory collection. And you can add any FieldCompareExpressionPredicate to the PredicateExpression you are using.

If you experiment problems, please be more specific in the search you are trying to achieve wink

David Elizondo | LLBLGen Support Team
jsaylor
User
Posts: 37
Joined: 20-Sep-2004
# Posted on: 08-May-2009 17:56:29   

daelmo wrote:

Hi Jeff,

You could perform a FindMatches on your in-memory collection. And you can add any FieldCompareExpressionPredicate to the PredicateExpression you are using.

If you experiment problems, please be more specific in the search you are trying to achieve wink

You are correct, I figured out how to do it (posting here in case it helps someone else):

        
Dim bit As Integer = 128
Dim bitEx As New PredicateExpression
bitEx.AddWithAnd(ScheduleEntryFields.ActionReason.SetExpression(New Expression(ScheduleEntryFields.ActionReason, ExOp.BitwiseAnd, bit)) = bit)
Dim bitMatches As List(Of Integer) = entries.FindMatches(bitEx)

But, it led me to another issue re: applying predicate expressions against discriminator fields of in-memory entities - which is the field I was trying to filter on above and actually the reason why I couldn't find any matches . I'm posting that in another thread...