如在设置中动态设置了以前条件(金额 >= 5000 and 
 人员类型 = '普通') or
 金额 >= 10000以上为三条数据存放在数据库中,其实的字段名与值还有运算符都是可编辑的。现在存在一单据,有没有方式在.net中判断该单据是否满足以上条件。而不是在数据库中。

解决方案 »

  1.   

    DataTable.Select 方法 示例:private void GetRowsByFilter()
    {
        DataTable table = DataSet1.Tables["Orders"];
        // Presuming the DataTable has a column named Date.
        string expression;
        expression = "Date > '1/1/00'";
        DataRow[] foundRows;    // Use the Select method to find all rows matching the filter.
        foundRows = table.Select(expression);    // Print column 0 of each returned row.
        for(int i = 0; i < foundRows.Length; i ++)
        {
            Console.WriteLine(foundRows[i][0]);
        }
    }
      

  2.   

    推荐LZ用LINQ 然后再用表达式,根据条件接接  Expression<Func<Entity.Coupon, bool>> filter = p => 1 == 1;
                filter =filter.And(p=>p.price>500 && xxx="普通").Or(p=>p.price>1000)
      

  3.   

    linq 不会的话,就用循环。得到所有的数据。
    bool isTrue=false;
    for(int i=0;i<count;i++)
    {
      if((金额>=5000 && 人员类型==“普通”)|| 金额>=10000  )
      {
         isTure=true;
       }
    }
    如果 条件是动态的。
    在后台拼接出sql 语句 查询出 个数。个数大于零 就满足条件。
      

  4.   

    “动态的啊。”table.Select(expression);这个方法的条件表达式,不就是要动态传入的吗,晕!你定义一个变量,动态赋值不就可以了
      

  5.   


    1.LINQ
    2.自己的逻辑算法。