Database stored sentences for checking class status
<p>I am inheriting a system in C#. I have lots of instructions in the database as follows:</p>

<pre><code>StartReal.IsEmpty() &amp;&amp; EstimatedStart.Date &lt; DateTime.Today.Date 
StartReal.IsEmpty() &amp;&amp; EstimatedStart.Date &gt; DateTime.Today.Date 
StartReal.IsEmpty() &amp;&amp; EstimatedStart.Date == DateTime.Today.Date
</code></pre>

<p>All fields belong to a class called TASKS. Now I'm breaking down each one of the sentences (splitting by AND/OR and by operator) and then doing the analysis of the sentence to have the desired result. This is leading to a very low performance. Is there any other type of operation that can be done?</p>

<p><strong>Edit</strong>: I'm obtaining a List from the DB that each one has RULECODE, DESCRIPTION and EXPRESSION (the ones above).
Then I'm splitting each expression twice:</p>

<pre><code>  private int TaskSituation(TasksBOL pTask, List&lt;SituationRulesBOL&gt; pRules)
  {
     string[] aCommands;
     char[] aSeparators = { '&amp;', '|' };
     char[] aOperators = { '=', '&lt;', '&gt;' };

     int iCode = 0;

     foreach (SituationRulesBOL o in pRules)
     {
        string sExpression = o.Expression;

        if (sExpression.Contains("&amp;&amp;") || sExpression.Contains("||"))
        {
           aCommands = sExpression.Split(aSeparators, System.StringSplitOptions.RemoveEmptyEntries);
        }

        iCode = CheckExpression(pTask, aCommands);
     }

     return iCode;
  }
</code></pre>

<p>The previous method gets each part of the sentence and splits it for AND/OR. Then it passes the Task information and the senteces to CheckExpression and makes another split by operator and compares to the Task dates.</p>