【发布时间】:2015-05-25 06:47:10
【问题描述】:
我有数据表,我正在尝试查找 Id 以特定值开头的列的总和。我尝试了一些方法但出现错误。
result=Convert.ToInt32(dtNew.Compute("Sum(ResPending)", "Substring(ID,0,1)='G'"));//error shows-- Substring() argument is out of range
也尝试过这种方式
dtNew.AsEnumerable().Where(x => x.Field<string>("ID").ToString().StartsWith("G"));//Expression can not contain lambda expression
【问题讨论】:
-
我怀疑你是在 Visual Studio 的“监视”窗口中执行了后者,不是吗?
-
//Expression can not contain lambda expression这个错误一般是在Watch窗口中尝试lambda的时候,你是直接在代码中尝试吗? -
@har07 更正。 VS 直到 2013 年(包括 2013 年)不支持观察程序中的 lambda 表达式。
-
sustring索引以1开头,stackoverflow.com/questions/23049995/…