首页 > 其他 > 详细

LinQ中合并、连接、相交、与非查询

时间:2016-04-21 10:19:29      阅读:184      评论:0      收藏:0      [点我收藏+]

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)

LinQ中合并、连接、相交、与非查询

原文:http://www.cnblogs.com/jinHaving/p/5415691.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!