.net - Convert Func(Of Type, Boolean) to Expression(Of Func(Of Type, Boolean))? -
i've got following code:
dim query iqueryable(of someobject) = new objectquery(of someobject)(querystring, db, mergeoption.notracking) .where(ctype(function(x) x.publish = true, expression(of func(of someobject, boolean))))
and gives me error says:
cannot convert expression of type func(someobject) system.nullable(of boolean) type system.linq.expressions.expression(of system.func(someobject, boolean)).
i have tried:
.where(ctype(function(x) x.publish = true, expression(of func(of someobject, nullable(of boolean)))))
which doesn't work either.
if don't have ctype where
comes narrowing conversion error iqueryable , ienumerable, need there, not sure how write parameter expression can converted. help?
don't use casting ctype
here - create expression directly:
dim expr expression(of func(of someobject, nullable(of boolean))) = function(x) x.publish = true dim query iqueryable(of someobject) = new objectquery(of someobject)(querystring, db, mergeoption.notracking) .where(expr)
expressions need created such. it's not possible convert existing func
expression.
Comments
Post a Comment