C
C#3w ago
kasen0177

Devexpress loadOptions parse filter array, how to handle in serverside

Anyone know how to parse the array or restructure to make it easier the syntax var filter = [ ["Product_Current_Inventory", "<>", 0], "or", [ ["Product_Name", "contains", "HD"], "and", ["Product_Cost", "<", 200] ] ]
8 Replies
friedice
friedice3w ago
$details
MODiX
MODiX3w ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, what you expect the result to be, what .NET version you are using and what platform/environment (if any) are relevant to your question. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
kasen0177
kasen01773w ago
[ ["Product_Current_Inventory", "<>", 0], "or", [ ["Product_Name", "contains", "HD"], "and", ["Product_Cost", "<", 200] ] ] oh yeah this is the format given by devexpress when you make remoteOperation = true and its part of an object return by the customStore. I am just trying to find a way to reformat this into somethinge easier to work with with the databasde @friedice
Keswiik
Keswiik3w ago
You've only reiterated the original post, not added any details that would make it easier to understand what you're doing. What is devexpress? What frameworks / etc are you using serverside? Any ORM or raw SQL? Because this looks to be some kind of query builder and without knowing how you're interacting with your database we can't really give suggestions.
kasen0177
kasen01773w ago
raw sql
kasen0177
kasen01773w ago
DevExtreme React - CustomStore LoadOptions - DevExtreme React Docum...
Discover the capabilities of our component and all available component via our online developer guides, code snippets, and interactive demos.
kasen0177
kasen01773w ago
its like a frontend library that handles UI/ and client side logic for those ui components im trying to do filter serverside, so it gives me this object thats quite hard to parse
[
[ "dataField", "=", 10 ],
"and",
[
[ "anotherDataField", "<", 3 ],
"or",
[ "anotherDataField", ">", 11 ]
]
]
[
[ "dataField", "=", 10 ],
"and",
[
[ "anotherDataField", "<", 3 ],
"or",
[ "anotherDataField", ">", 11 ]
]
]
so basically i want to transform that into raw sql
Keswiik
Keswiik3w ago
Well, it'd be easy to make some kind of QueryPredicate class that is created by parsing that object, which you could .ToString() (or create a .ToSql() method) to turn into a valid query predicate.