zoukankan      html  css  js  c++  java
  • datatable linq查询操作filed用法

    https://msdn.microsoft.com/zh-cn/library/bb386916.aspx

      int iEmailCount1 = ds.Tables[0].AsEnumerable().Where(x => x.Field<string>("Email") != "").GroupBy(x => x.Field<string>("Email")).Count();

    // Fill the DataSet.
    DataSet ds = new DataSet();
    ds.Locale = CultureInfo.InvariantCulture;
    FillDataSet(ds);
    
    DataTable products = ds.Tables["Product"];
    
    var query =
        from product in products.AsEnumerable()
        where product.Field<string>("Color") == "Red"
        select new
        {
            Name = product.Field<string>("Name"),
            ProductNumber = product.Field<string>("ProductNumber"),
            ListPrice = product.Field<Decimal>("ListPrice")
        };
    
    foreach (var product in query)
    {
        Console.WriteLine("Name: {0}", product.Name);
        Console.WriteLine("Product number: {0}", product.ProductNumber);
        Console.WriteLine("List price: ${0}", product.ListPrice);
        Console.WriteLine("");
    }








    /*********************************************************************************/
    DataSet ds = new DataSet();
    ds.Locale = CultureInfo.InvariantCulture;
    FillDataSet(ds);
    
    DataTable products = ds.Tables["Product"];
    
    var query =
        from product in products.AsEnumerable()
        where !product.IsNull("Color") &&
            (string)product["Color"] == "Red"
        select new
        {
            Name = product["Name"],
            ProductNumber = product["ProductNumber"],
            ListPrice = product["ListPrice"]
        };
    
    foreach (var product in query)
    {
        Console.WriteLine("Name: {0}", product.Name);
        Console.WriteLine("Product number: {0}", product.ProductNumber);
        Console.WriteLine("List price: ${0}", product.ListPrice);
        Console.WriteLine("");
    }
  • 相关阅读:
    作为管理者的基本职责
    websocket接口自动化的封装
    locust性能测试的使用
    git的协作提交流程
    关于接口自动化的实施步骤
    K8S的组件梳理
    jenkins pipeline中,失败后获取异常不中断业务
    pipline在执行的docker镜像中添加hosts
    sonar搭建
    django
  • 原文地址:https://www.cnblogs.com/liziqiang/p/6707503.html
Copyright © 2011-2022 走看看