Sql Net Linq with datatables-从一个表中选择另一个表中不存在的内容
我有两个数据,我应用linq选择了一些行:Sql Net Linq with datatables-从一个表中选择另一个表中不存在的内容,sql,vb.net,linq,Sql,Vb.net,Linq,我有两个数据,我应用linq选择了一些行: csql = "select * from V_Vente where code_projet=" & ComProjet.GetColumnValue("code_projet") & " " Dim tabVnt as Datatable = utilitaire.getDatatable(csql) Dim query1 = tabVnt.AsEnumerable().Where(Function(r) DirectCast(r
csql = "select * from V_Vente where code_projet=" & ComProjet.GetColumnValue("code_projet") & " "
Dim tabVnt as Datatable = utilitaire.getDatatable(csql)
Dim query1 = tabVnt.AsEnumerable().Where(Function(r) DirectCast(r("date"), Date) >= dtDu And DirectCast(r("date"), Date) <= dtAu)
Dim tabAnnule As DataTable = utilitaire.getDatatable("select * from V_Reserv_Annule")
Dim query2 = From cust In tabAnnule.AsEnumerable() Where (cust.type = "définitif" Or cust.type = "Transfert") And cust.date_annule <= dtAu
如果我正确理解了您的代码,您可以检查第二个表的
Num\u r
s是否不包含表一Num\u r
:
Dim rows = t1.Where(x=> !t2.Select(y=> y.Num_r).Contains(x.Num_r));
我已经找到了我的问题的解决方案,我想在这里与您分享:
Dim csql = "select * from V_Vente where code_projet=" & ComProjet.GetColumnValue("code_projet") & " "
Dim tabVnt As DataTable = utilitaire.getDatatable(csql)
Dim query1 = tabVnt.AsEnumerable().Where(Function(r) DirectCast(r("date"), Date) >= dt1 And DirectCast(r("date"), Date) <= dt2).ToList
Dim tabAnnule As DataTable = utilitaire.getDatatable("select * from V_Reserv_Annule")
bannedCCList = From c In tabAnnule.AsEnumerable() _
Where (c!type.Equals("définitif") = True Or c!type.Equals("Transfert") = True) And c!date_annule <= dt2
Select c.Field(Of String)("num_recu")
Dim exceptData = (From c In query1.AsEnumerable() _
Where Not bannedCCList.Contains(c.Field(Of String)("num_recu")) _
).ToList
Dim csql=“从V_Vente where code_projet=“&ComProjet.GetColumnValue(“code_projet”)&”中选择*
Dim tabVnt As DataTable=utilitaire.getDatatable(csql)
Dim query1=tabVnt.AsEnumerable()。其中(函数(r)DirectCast(r(“日期”),date)>=dt1和DirectCast(r(“日期”),date)
Dim csql = "select * from V_Vente where code_projet=" & ComProjet.GetColumnValue("code_projet") & " "
Dim tabVnt As DataTable = utilitaire.getDatatable(csql)
Dim query1 = tabVnt.AsEnumerable().Where(Function(r) DirectCast(r("date"), Date) >= dt1 And DirectCast(r("date"), Date) <= dt2).ToList
Dim tabAnnule As DataTable = utilitaire.getDatatable("select * from V_Reserv_Annule")
bannedCCList = From c In tabAnnule.AsEnumerable() _
Where (c!type.Equals("définitif") = True Or c!type.Equals("Transfert") = True) And c!date_annule <= dt2
Select c.Field(Of String)("num_recu")
Dim exceptData = (From c In query1.AsEnumerable() _
Where Not bannedCCList.Contains(c.Field(Of String)("num_recu")) _
).ToList