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("");
    }
  • 相关阅读:
    layui镜像站文档
    mysql 查询 包含哪个字符串
    laydate时间点击后马上消失
    timer_dma_enable
    map文件堆栈大小
    回调函数
    复位电路
    stm32 map文件的分析
    如何在VSCode里面写代码进行调试和运行
    DMA为CPU减负
  • 原文地址:https://www.cnblogs.com/liziqiang/p/6707503.html
Copyright © 2011-2022 走看看