<i id='UWxdh'><tr id='UWxdh'><dt id='UWxdh'><q id='UWxdh'><span id='UWxdh'><b id='UWxdh'><form id='UWxdh'><ins id='UWxdh'></ins><ul id='UWxdh'></ul><sub id='UWxdh'></sub></form><legend id='UWxdh'></legend><bdo id='UWxdh'><pre id='UWxdh'><center id='UWxdh'></center></pre></bdo></b><th id='UWxdh'></th></span></q></dt></tr></i><div id='UWxdh'><tfoot id='UWxdh'></tfoot><dl id='UWxdh'><fieldset id='UWxdh'></fieldset></dl></div>

      <bdo id='UWxdh'></bdo><ul id='UWxdh'></ul>
    <legend id='UWxdh'><style id='UWxdh'><dir id='UWxdh'><q id='UWxdh'></q></dir></style></legend>

      <small id='UWxdh'></small><noframes id='UWxdh'>

    1. <tfoot id='UWxdh'></tfoot>

      如何计算 LINQ 中 DataTable 的列的总和(到数据集)

      时间:2023-06-05

    2. <legend id='DRIEq'><style id='DRIEq'><dir id='DRIEq'><q id='DRIEq'></q></dir></style></legend>
        <i id='DRIEq'><tr id='DRIEq'><dt id='DRIEq'><q id='DRIEq'><span id='DRIEq'><b id='DRIEq'><form id='DRIEq'><ins id='DRIEq'></ins><ul id='DRIEq'></ul><sub id='DRIEq'></sub></form><legend id='DRIEq'></legend><bdo id='DRIEq'><pre id='DRIEq'><center id='DRIEq'></center></pre></bdo></b><th id='DRIEq'></th></span></q></dt></tr></i><div id='DRIEq'><tfoot id='DRIEq'></tfoot><dl id='DRIEq'><fieldset id='DRIEq'></fieldset></dl></div>

            <tfoot id='DRIEq'></tfoot>

                <bdo id='DRIEq'></bdo><ul id='DRIEq'></ul>

                <small id='DRIEq'></small><noframes id='DRIEq'>

                  <tbody id='DRIEq'></tbody>
                本文介绍了如何计算 LINQ 中 DataTable 的列的总和(到数据集)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我刚刚开始阅读 LINQ,我想开始将它整合到我的代码中.我知道如何通过Foreach"遍历行或在特定列上执行 compute.sum 来计算 DataTable 列的总和.如何使用 LINQ to DataSet 进行等效操作?

                I'm just started to read up on LINQ and I want to start incorporating it into my code. I know how to compute the sum of a DataTable's column by either "Foreach"-ing through the rows or by doing a compute.sum on the specific column. How do I do the equivalent with LINQ to DataSet?

                推荐答案

                如果没有类型(将 int 替换为正确的数据类型):

                If untyped (replace int with the correct data type):

                 var sum = table.AsEnumerable().Sum(x=>x.Field<int>(3));
                

                或:

                 var sum = table.AsEnumerable().Sum(x=>x.Field<int>("SomeProperty"));
                

                如果输入:

                 var sum = table.Sum(x=>x.SomeProperty);
                

                这篇关于如何计算 LINQ 中 DataTable 的列的总和(到数据集)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:总和可为空的 Linq 查询 下一篇:Linq 按日期获取数据组的总和

                相关文章

                最新文章

                <legend id='gXHHY'><style id='gXHHY'><dir id='gXHHY'><q id='gXHHY'></q></dir></style></legend>
                  <tfoot id='gXHHY'></tfoot>
                1. <i id='gXHHY'><tr id='gXHHY'><dt id='gXHHY'><q id='gXHHY'><span id='gXHHY'><b id='gXHHY'><form id='gXHHY'><ins id='gXHHY'></ins><ul id='gXHHY'></ul><sub id='gXHHY'></sub></form><legend id='gXHHY'></legend><bdo id='gXHHY'><pre id='gXHHY'><center id='gXHHY'></center></pre></bdo></b><th id='gXHHY'></th></span></q></dt></tr></i><div id='gXHHY'><tfoot id='gXHHY'></tfoot><dl id='gXHHY'><fieldset id='gXHHY'></fieldset></dl></div>

                      <bdo id='gXHHY'></bdo><ul id='gXHHY'></ul>

                    <small id='gXHHY'></small><noframes id='gXHHY'>