Looking for a way to parse large input conditions to select output
I have been thinking about this problem for long enough but cannot come up with something satisfactory. hope someone can help me out.
I am writing a data entry (database) program that accepts a large number of input (strings, numbers and relationships). The objective of this program is to take all the inputs and run them against a list of conditions, and where a condition is true, it will return a set of outputs (item IDs) that will go into the final report.
My current implementation is as such (simplified): I have a "Trigger" table with the following columns:
1.ITEM_SET (e.g. 001;105;112)
2.TABLE(e.g. [Dimension] INNER JOIN [Product] ON [id])
3.CONDITION (e.g. [Dimension].[width] > 20 AND [Product].[color] = "Red")
Then I will go
triggers = SELECT * FROM Trigger
foreach(trigger in Triggers)
{
items = SELECT trigger.ITEM_SET FROM trigger.TABLE WHERE trigger.C开发者_运维技巧ONDITION
if(have items) report.items.add(items)
}
This certainly is a pain to enter every (almost 5000) conditions... I am looking for a simpler way to do this such that it is easily extensible, by the user themselves. Any ideas?
While it does not totally solve all the associated problems i had, I modified the circumstances and http://ncalc.codeplex.com/ was able to fill the holes. Thanks NCalc!
精彩评论