以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  如何用LINQ进行左联接查询?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=140442)

--  作者:九易六
--  发布时间:2019/9/5 17:02:00
--  如何用LINQ进行左联接查询?
 左表有10条数据,右表有6条数据,想通过左联接查询出右表缺失了哪些数据。

Dim drs = from dr In DataTables("表A").DataRows
          Group Join dr2 In DataTables("表B").DataRows on dr("第一列") equals dr2("第一列")
                Into dr3 = Group
          from dr4 In dr3 
            Select dr

For Each dr As DataRow In drs
    Output.Show(dr("第一列"))
Next

现在通过上面的语句,能够查询出“相同的部分”。请问如何查询出差异的部分呢?

--  作者:有点蓝
--  发布时间:2019/9/5 17:26:00
--  

Dim drs =  from dr In DataTables("表A").DataRows 
    where not (from dr2 In DataTables("表B").DataRows 
        Select dr2("第一列")).Contains(dr("第一列"))    

For Each dr As DataRow In drs
    Output.Show(dr("第一列"))
Next