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; }
    }

  • 相关阅读:
    【javascript】select操作实例
    【javascript】函数
    【javascript】一些资料
    【javascript】操作符:一元操作符
    动态执行Sql
    索引( index )
    事务
    用户相关
    视图(view)
    函数(function)
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/2867403.html
Copyright © 2011-2022 走看看