C# DataTable Compute方法的使用
在开发中需要对DataTable的数据进行处理,比如累加,求最大最小及平均值等,以前都采用手工对DataTable进行循环并计算的方式,现在发现DataTable的Compute方法可以轻松实现这些功能。
https://msdn.microsoft.com/zh-cn/library/system.data.datatable.compute.aspx
语法:
DataTable.Compute("expression","filter");
其中:Expression是要计算的表达式,Filter是要限制在表达式中进行计算的行的筛选器,均是string类型。
Expression:
sum(列名),avg(列名),sum(列名),min(列名),max(列名),count(列名)
例:
DataTable有列"Column1"和"Column2”
DataTable.Compute("Sum(Column1)","") //对Column1进行求和
DataTable.Compute("Sum(Column1)","Column2=5") //对Column2的值为5的Column1进行求和
C# DataTable Compute方法的使用的更多相关文章
- DataTable.Compute方法使用实例
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...
- DataTable.Compute()用法
DataTable.Compute()用法 2010-04-07 11:28 一.DataTable.Compute()方法說明如下 作用: 计算用来传递筛选条件的当前行上的给定表达 ...
- 转:DataTable.Compute()用法
转自:http://www.cnblogs.com/fanyf/archive/2012/05/11/2495919.html一.DataTable.Compute()方法說明如下 作用: 计算用来传 ...
- C# DataTable.Compute()用法
DataTable.Compute()用法 2010-04-07 11:28 一.DataTable.Compute()方法說明如下 作用: 计算用来传递筛选条件的当前行上的给定表达 ...
- DataTable.Compute()
一.DataTable.Compute()方法說明如下 作用: 计算用来传递筛选条件的当前行上的给定表达式. 格式為: Object Compute (string ...
- C#中DataTable中的Compute方法使用收集
原文: C#中DataTable中的Compute方法使用收集 Compute函数的参数就两个:Expression,和Filter. Expresstion是计算表达式,关于Expression的详 ...
- [datatable]借助DataTable的Compute方法
借助DataTable的Compute方法,DataTable中数据不用事先排好序. 下面代码中的dt是跟前面的是一样的 DataTable dtName = dt.DefaultView.ToTab ...
- c# 基于DataTable的Compute方法的扩展
DataTable.Compute(String, String) 方法 定义 命名空间:System.Data 程序集:System.Data.dll, netstandard.dll, Syste ...
- 转载 C#中DataTable中的Compute方法使用收集
原文: C#中DataTable中的Compute方法使用收集 Compute函数的参数就两个:Expression,和Filter. Expresstion是计算表达式,关于Expression的详 ...
随机推荐
- 记录用户操作历史命令history
我们知道可以使用history命令,查看自己的操作记录,但如果你是root用户,如何查看其它用户的操作记录呢? 其实history命令只是把当前用户目录下的~/.bash_History文件内容列 ...
- Shell--基础知识
变量的定义: a=1 b=hello c="hello world !" d='hello "反启" !' e=`ls` (注意:这是反引号) 备注:=号左右 ...
- oracle之用户名密码包含特殊字符时候怎么使用sqlplus登录
oracle有时候用户密码包含一些特殊字符直接登录会报错,需要使用以下方式登录sqlplus sqlplus 'username/"password"' PS:整体使用单引号括起来 ...
- 系统中同时有 python2和 python3,怎么让 ipython 选择不同的版本启动?
已经安装的情况下: > which ipython /usr/local/bin/ipython > cat /usr/local/bin/ipython #!/usr/local/op ...
- Python开发【Django】:Admin配置管理
Admin创建登录用户 数据库结构表: from django.db import models # Create your models here. class UserProfile(models ...
- 小米范工具系列之一:小米范 web查找器
最新版本1.5,下载地址:http://pan.baidu.com/s/1c1NDSVe 文件名web finder,请使用java1.8运行 小米范 web查找器主要功能为快速端口扫描,并识别we ...
- (2.16)Mysql之SQL基础——函数
(2.16)Mysql之SQL基础——函数 关键词:mysql函数,mysql自定义函数,mysql聚合函数,mysql字符串函数,mysql数值函数 1.自定义函数 -- (1)一般形式 creat ...
- 关于RxJava背压
http://flyou.ren/2017/04/05/%E5%85%B3%E4%BA%8ERxJava%E8%83%8C%E5%8E%8B/?utm_source=tuicool&utm_m ...
- 在Mybatis中使用连表查询的一次实际应用
以前在工作中很少使用多表关联查询,对连表查询的具体作用和使用场景也没有很直观的认识,通过这次在项目中的实际应用,对此有了一定的认识,特记录如下. 关联表介绍: 分别是属性表attr_info.属性值表 ...
- 77. Combinations(回溯)
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: I ...