• 对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();        

         }

  • 相关阅读:
    [LeetCode] Binary Tree Preorder Traversal
    Linux下搭建JSP环境
    Linux系统捕获数据包流程
    如何使用Linux套接字?
    IPod在Linux下的实战
    将手机流氓软件彻底赶出去
    如何修复和检测Windows系统漏洞
    防止网络渗透措施两则
    Cisco安全防护读书笔记之一Cisco系统设备协议漏洞
    至顶网推荐-Rpm另类用法加固Linux安全
  • 原文地址:https://www.cnblogs.com/yinchuan/p/5297161.html
Copyright © 2020-2023  润新知