c# - storing and parsing boolean expressions in database -


this follow-up question previous question which design pattern suitable workflow requirement?. know best way store boolean expression in database , evaluate @ runtime without effort. have requirement set of jobs need executed screen every month-end , decision of whether job can executed depends on outcome of previous jobs. should able save expression in database e = (a or b) , (c or d) (could complex nested expression). means e can run if or b successful , c or d successful. how can represented in database , parsed , condition evaluated later?

thinking of doing (not tested yet)
if "job e = (a , b) or (c , d)". store tree structure in table

 jobid dependentjobid successjobid failurejobid e                    b             c               e        c             d             0 e        d             1             0 e        b             1             0 

this means "if successful, check b else check c", "if c successful check d". process starts highest node no "dependentjobid" , stops @ leaf node. use dummy job ids "1" success , "0" failure. if leaf node zero, job allowed run. not sure how best can evaluate in t-sql. may have use recursive function.

technology used: asp.net 3.5, c# 3.0, sql server 2008

you can store expressions strings in database , parse them @ runtime using either set of custom functions, or existing engine. achieve have used below in previous projects:

flee (fast lightweight expression evaluator)

dynamic linq

i dynamic linq easier go can construct clause using familiar linq / c# syntax , store string in database. have used flee in projects wanted construct own simple query language lot of these acheive using dynamic linq.


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

c# - Getting "Internal .Net Framework Data Provider error 30" error when column has NULL value -

c++ - How to modify context menu of internet explorer using IDocHostUIHandler::ShowContextMenu? -