• DataTable 筛选数据,弃用Select()方法


    筛选出 2012-2-1 的数据

    private DataTable GetData()
    {
    DataTable dt = new DataTable();

    dt.Columns.Add("Id", typeof(int));
    dt.Columns.Add("Time", typeof(string));

    dt.Rows.Add(1, "2012-2-1");
    dt.Rows.Add(2, "2012-2-2");
    dt.Rows.Add(3, "2012-2-3");
    dt.Rows.Add(4, "2012-2-4");
    dt.Rows.Add(5, "2012-2-5");
    dt.Rows.Add(6, "2012-2-1");
    dt.Rows.Add(7, "2012-2-2");
    dt.Rows.Add(8, "2012-2-2");
    dt.Rows.Add(9, "2012-2-1");


    dt = dt.AsEnumerable().Where(o => DateTime.Parse(o.Field<string>("Time")) == DateTime.Parse("2012-2-1")).CopyToDataTable();

    return dt;
    }

  • 相关阅读:
    SonarQube
    Gerrit
    Jenkins
    Jenkins
    GitLab
    GitLab
    GitLab
    centos7配置国内yum源
    CentOS7 ping: unknown host www.baidu.com
    VirtualBox下安装CentOS7系统
  • 原文地址:https://www.cnblogs.com/luyiwei/p/3718465.html
Copyright © 2020-2023  润新知