zoukankan      html  css  js  c++  java
  • LinQ中合并、连接、相交、与非查询

    LinQUnion合并查询连接不同的集合,自动过滤相同项;延迟。即是将两个集合进行合并操作,过滤相同的项

     

    var cities = (from p in mylinq.System_Places
    
              where p.PID == place
    
              select p).Union(
    
              from q in mylinq.System_Places
    
              where q.Parentid==place
    
              select q
    
              );
    

    LinQ中的Concat连接查询连接不同的集合,不会自动过滤相同项;延迟。

    (from p in System_Places
    
         where p.PID == 1010
    
         select p).Concat(
    
           from q in System_Places
    
             where q.Parentid==1010
    
             select q
    
             ).Concat(
    
               from n in System_Places
    
                 where n.Parentid==1010
    
                  select n
       )
    
     

    LinQ中的Intersect相交查询:获取不同集合的相同项(交集),即两集合都出现的项。

    (from c in Bst_System_Places
    
      select c.CnPlaceName).Intersect(
    
      from e in Bst_Company_Jobs
    
      select e.WorkPlace)
    

    LinQ中的Except与非查询:排除相交项,即从某集合中排除与另一集合中相同的项,以前集合为主。。。

    (from e in Bst_Company_Jobs
    
      select e.WorkPlace).Except(
    
      from c in Bst_System_Places
    
      select c.CnPlaceName)
    


    转自:http://mwga.net.blog.163.com/blog/static/106456728201063044736712/

  • 相关阅读:
    并查集
    结构体字节对齐
    Dijkstra算法(单源最短路径)
    图的遍历
    二叉树的非递归遍历
    浅谈C语言中的联合体
    二叉排序(查找)树
    KMP算法
    C语言文件操作解析(四)
    Trie树
  • 原文地址:https://www.cnblogs.com/kinpauln/p/1813431.html
Copyright © 2011-2022 走看看