dynamic-linq-query-builder icon indicating copy to clipboard operation
dynamic-linq-query-builder copied to clipboard

Question: Returning All Values that match Any Condition

Open du8die opened this issue 7 years ago • 0 comments

Good Morning,

First, let me start by saying that my use case is certainly non-traditional. So - this question may be beyond the scope of this library - or at the least, I'm trying to stuff a square peg into a round hole.

Background: I'm currently building a "Logic" column for an adHoc query engine. The idea is this - pull Column 1 and Column 2 out of the database. The logic column will basically say (using the jQuery QueryBuilder tool) if Column 1 = 35 and Column 2 >= 50 then display a message. So, I'm really trying to use the library to determine if a set of data meets the rules.

Data:

Set #1:
//Should return false
[
{ "id":1, "value": 99},
{ "id":2, "value": 98}
]

Set #2:
//Should return true
[
{ "id":1, "value": 99},
{ "id":2, "value": 99}
]

Dynamic Query

{
   'Condition':'AND',
   'Rules':
      [
         {
            'Condition':'AND',
            'Rules':
               [
                  {
                     'Condition':null,
                     'Field':'id',
                     'Id':'id',
                     'Input':'text',
                     'Operator':'equal',
                     'Rules':null,
                     'Type':'string',
                     'Value':'1'
                  },
                  {
                     'Condition':null,
                     'Field':'value',
                     'Id':'value',
                     'Input':'text',
                     'Operator':'equal',
                     'Rules':null,
                     'Type':'integer',
                     'Value':'99'
                  }
               ]
         },
         {
            'Condition':'AND',
            'Rules':
               [
                  {
                       'Condition':null,
                        'Field':'id',
                        'Id':'id',
                        'Input':'text',
                        'Operator':'equal',
                        'Rules':null,
                        'Type':'string',
                        'Value':'2'
                     },
                     {
                        'Condition':null,
                        'Field':'value',
                        'Id':'value',
                        'Input':'text',
                        'Operator':'equal',
                        'Rules':null,
                        'Type':'integer',
                        'Value':'99'
                  }
               ]
         }
      ]
}

I know why this isn't working - but I don't know how to fix it. There are no objects that meet all conditions. I can't use OR because that will return one or the other - not both.

What am I missing? I know in LINQ there is an ANY operator, and that (I think) should work, but it isn't available (as far as I can tell) in ExpressionTrees.

I'm stumped. Any ideas, suggestions, things to try - would be greatly appreciated. The querybuilder is the right tool - and I think this library is probably capable of doing what I need (even with a bit of modification) - but I don't have any clue where to start.

Thanks!

du8die avatar Jun 02 '18 15:06 du8die