zoukankan      html  css  js  c++  java
  • GenericQuery

    List<Store> StoreList = new List<Store>
    {
    new Store { WareHouse="一号仓库", Product="电视机", Quantity=10 },
    new Store { WareHouse="一号仓库", Product="电视机", Quantity=20 },
    new Store { WareHouse="一号仓库", Product="洗衣机", Quantity=30 },
    new Store { WareHouse="二号仓库", Product="洗衣机", Quantity=40 }
    };

    var query = ConditionQuery<Store>(StoreList, itm => itm.WareHouse == "一号仓库");
    GridView1.DataSource = query;
    GridView1.DataBind();
    //var query2 = ConditionQuery<Store>(StoreList, itm => itm.Product == "洗衣机");
    //GridView1.DataSource = query2;
    //GridView1.DataBind();

    //List<int> ints = new List<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    //var qry = ConditionQuery<int>(ints, itm => itm % 2 == 0);
    //foreach (var item in qry)
    //{
    // Response.Write(item.ToString() + ",");
    //}

    public IEnumerable<TSource> ConditionQuery<TSource>(IEnumerable<TSource> source, Func<TSource, bool> condition)
    {
              return source.Where(condition);
    }

    class Store
    {
    public string WareHouse { get; set; }
    public string Product { get; set; }
    public int Quantity { get; set; }
    }

  • 相关阅读:
    多项式A除以B (25分)
    numpy随笔
    numpy中文件读取操作np.loadtxt(),np.savetxt()的使用
    Plug It In
    C. Uncle Bogdan and Country Happiness
    获得系统版本号
    C# Winform无边框窗口拖动
    numericUpDown隐藏上下箭头
    C# FTP下载图片转为Base64
    C# 获取版本号
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/2867403.html
Copyright © 2011-2022 走看看