重载解析失败,因为在Vb.net中使用Predicatebuilder时,没有可访问的'And'接受此数量的参数

时间:2017-07-25 12:58:08

标签: vb.net linq predicatebuilder

我正在尝试使用vb.net中的谓词构建器构建动态Linq查询。但是,当我尝试使用Predicate“And”子句来过滤我的查询时,会出现以下错误。  这里没有类似的问题得到解答。

这是我的代码:

Dim ds As DataTable = loaddata("Select i.itm_code AS Code,itm_barcode AS Barcode,itm_Description As Description,itm_price AS Price,subgrp_name AS Subgroup, itm_expiry, Itm_Active As Visible, itm_Featured AS Featured, ITM_PHOTO AS PHOTO, ITM_BRAND AS Brand, ITM_TITLE AS Title, ITM_SIZE AS SIZE, ITM_MEASUREMENT AS UNIT from items i, groups g, subgroups s, item_barcode b Where i.itm_code = b.itm_code AND i.itm_Subgroup = s.SubGrp_ID")

 Dim tmp As IEnumerable(Of DataRow) = New DataTable().AsEnumerable()

Dim predicate As System.Linq.Expressions.Expression(Of Func(Of DataRow, Boolean)) = PredicateBuilder.True(Of DataRow)()

'错误出现在这里

predicate = predicate.And(Function(x As DataRow) x("ITM_BRAND") = brand)


tmp = ds.AsEnumerable().Where(predicate.Compile())

这是我在(http://www.albahari.com/nutshell/predicatebuilder.aspx

的类库中的Predicatebuilder类

enter image description here

0 个答案:

没有答案