查询结果计数为0

时间:2014-08-06 08:40:30

标签: vb.net linq

我想知道为什么这个查询有一个空结果列表,两个DataTable都有条目。我认为字段的串联可能是问题,但我找不到类似的例子。

Dim query = (From a In DT_Nachricht.AsEnumerable() _
             Join b In DT_Nachricht_filter.AsEnumerable() _
                 On (a.Field(Of String)("land") & a.Field(Of String)("tel") & a.Field(Of String)("ort")) _
                 Equals b.Field(Of String)("land_tel_ort") _
             Select New With _
             { _
                 .land = a.Field(Of String)("land" + "tel" + "ort"), _
                 .tel = b.Field(Of String)("land_tel_ort") _
             }).ToList()

1 个答案:

答案 0 :(得分:0)

我认为您的问题出在此处:a.Field(Of String)("land") & a.Field(Of String)("tel") & a.Field(Of String)("ort")

尝试:

Dim query = (From a In DT_Nachricht.AsEnumerable() _
         let land = a.Field(Of String)("land") & a.Field(Of String)("tel") & a.Field(Of String)("ort")
             Join b In DT_Nachricht_filter.AsEnumerable() _
                 On land Equals b.Field(Of String)("land_tel_ort") _
             Select New With _
             { _
                 .land = land, _
                 .tel = b.Field(Of String)("land_tel_ort") _
             }).ToList()