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)
    

      

     

  • 相关阅读:
    爬虫框架scrapy(1)持久化存储的多种方式及多页爬取数据
    爬虫之selenium
    redis相关
    爬虫之数据解析
    爬虫之requests模块2
    爬虫之requests模块
    HTTP和HTTPS协议
    Pymongo使用
    MongoDB
    python网络编程之黏包问题
  • 原文地址:https://www.cnblogs.com/wolfocme110/p/5706063.html
Copyright © 2011-2022 走看看