如何在没有DataTables的情况下评估列表达式 [英] How to evaluate column expressions without DataTables

查看:59
本文介绍了如何在没有DataTables的情况下评估列表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来评估ADO.NET中可用的列表达式...而不使用DataTable实例。

I’m looking for a way to evaluate the column Expression available in ADO.NET … without using a DataTable instance.

假设我有一个像iif这样的列表达式(a> b,true,false)

Say I have a column expression like iif(a > b, true, false)

有没有办法通过传递a和b的某种方式来计算这个表达式?

Is there a way to evaluate this expression by passing somehow values for a and b?

我查看了DataTable上的  计算方法,但它并不是我想要的:

I looked at the  Compute method on DataTable but it is not quite what I’m looking for:

object result1 = new DataTable()。Compute(" 20.0 / 2",null);

object result1 = new DataTable().Compute("20.0 / 2", null);

object result3 = new DataTable()。Compute(" iif(10> 5,true,false)",null);

object result3 = new DataTable().Compute("iif(10 > 5, true, false)", null);

object result2 = new DataTable()。Compute(" iif(a> b,true,false)",null); - 如何评估这个

object result2 = new DataTable().Compute("iif(a > b, true, false)", null); -- how to evaluate this

这背后的想法是出于性能原因从DataTable转移到简单的数组结构。

Idea behind this is to move away from DataTable to simple array structure for performance reason.

我还需要支持一种生成使用的遗留表达式的方法。

Still I need to support a way to generate the legacy expression used.

我宁愿避免构建表达式字符串来生成它,因为对于大量行来说它的性能会很差。

I would rather avoid building the expression string to generate this as it will be poor performance for large number of rows.

预先感谢您的帮助

Nick




推荐答案

如果表达式是预定义的,那么你可以写

  
a = ...

   b = ...

   result2 = a> b;

   a = …
   b = …
   result2 = a > b;


这篇关于如何在没有DataTables的情况下评估列表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆