DataTable.Compute不支持round之类的函数,可以调用JScript实现。
1、添加引用Microsoft.Vsa和Microsoft.JScript
2、例子代码
object ret1 = Microsoft.JScript.Eval.JScriptEvaluate("Math.round(0.60)", Microsoft.JScript.Vsa.VsaEngine.CreateEngine()); string s = "function test(a,b){return a*b};" + System.Environment.NewLine;
string s1 = "test(2,3)" + System.Environment.NewLine;
object ret2 = Microsoft.JScript.Eval.JScriptEvaluate(s + s1, Microsoft.JScript.Vsa.VsaEngine.CreateEngine());
3、执行结果
ret1=1,ret2=6