datatable里的参数调用c#方法

datetable调用函数,一般可以在数据库里加函数。因为c#已经写好了,再转过去比较耗时间,也不一定能转过去,所以用了这种方法:先查出datetable,用参数直接调用c#方法。
 
Func<int, int> customMethod = x => x * x;
 
foreach (DataRow row in table.Rows)
{
int value = (int)row["Value"];
row["Value"] = customMethod(value); // 调用自定义方法并更新DataRow
}
posted @ 2024-04-25 18:02  yinghualeihenmei  阅读(31)  评论(0)    收藏  举报