zoukankan      html  css  js  c++  java
  • 对datatable进行linq过滤

    实例:

    DataTable data = new DataTable();         

    data.Columns.Add("schoolid", Type.GetType("System.Int32"));           

     data.Columns.Add("ccid", Type.GetType("System.Int32"));

                DataRow newRow1 = data.NewRow();          

       newRow1["schoolid"] = 2;          

       newRow1["ccid"] = 1;            

    data.Rows.Add(newRow1);

                DataRow newRow2 = data.NewRow();          

       newRow2["schoolid"] = 2;         

        newRow2["ccid"] = 2;          

       data.Rows.Add(newRow2);

       DataRow newRow3 = data.NewRow();      

      newRow3["schoolid"] = 1;           

      newRow3["ccid"] = 2;            

    data.Rows.Add(newRow3);           

      string ceshi = "1,2";            

    var dataSelect = data.AsEnumerable();       

          dataSelect = from r in dataSelect                  

            where r.Field<int>("schoolid") == 2 && !(new int?[] {int.Parse(ceshi) }).Contains(r.Field<int>("ccid"))                          select r;                         foreach (DataRow row in dataSelect)        

         {                

      string schoolid = row["schoolid"].ToString();            

         string ccid = row["ccid"].ToString();        

         }

  • 相关阅读:
    JAVA_SE基础——35.static修饰成员函数
    Mybatis环境搭建
    搭建Mybatis环境遇到的问题
    Windows10系统下,彻底删除卸载MySQL
    StringBuffer类append方法的用法和用途
    Listener监听器
    Filter过滤器
    JSTL
    EL表达式
    JSP
  • 原文地址:https://www.cnblogs.com/yinchuan/p/5297161.html
Copyright © 2011-2022 走看看