且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将列值与c#.net中数据表中的所有其他列值相乘

更新时间:2023-08-25 23:22:10

这应该有帮助: DataColumn.Expression属性(System.Data) [ ^ ]和:创建表达式列| Microsoft Docs [ ^ ](包含代码示例)



更新:如果您的意思是自动填充,然后你需要手动执行 - 从原始DataTable中获取数据并生成一个新数据......这样的事情:

This should help: DataColumn.Expression Property (System.Data)[^] and this: Creating Expression Columns | Microsoft Docs[^] (code samples included)

UPDATE: If you mean auto-populate, then you need to do that manually - take the data from your original DataTable and generate a new one... Something like this:
DataTable ExpandDataTable(DataTable dt)
{
    var dt = new DataTable();
    // configure columns
    // iterate and build new DataTable
    return dt;
}