i know if there way (and proper) retrieves properties logicalbinaryexpression
, if it's possible.
i have :
dim whereclause expression(of func(of foo, boolean)) = function(f foo) f.id = 1 dim strignifiedwhereclause string = me.amethodwhichhandlesthis(whereclause)
in amethodwhichhandlesthis
methods, have each properties compare. if these, i'm fine rest of code... part of getting properties out of logicalbinaryexpression! read somewhere should not @ never says... why, , how can if it's not real?
sorry english, talk french.
to extract information expression recommend use custom visitor.
the following visitor return "id = 1"
when execute expression :
public class wherevisitor inherits expressionvisitor public shared function stringify(expression expression) string dim visitor new wherevisitor() visitor.visit(expression) return visitor.value end function public sub new() me._value = new stringbuilder() end sub private _value stringbuilder public readonly property value() string return me._value.tostring() end end property protected overrides function visitbinary(node binaryexpression) expression ' node.left , node.right not of type ' have check type , maybe use visitor ' obtain information want dim left memberexpression = ctype(node.left, memberexpression) dim right constantexpression = ctype(node.right, constantexpression) me._value.appendline(string.format("{0} = {1}", left.member.name, right.value)) return mybase.visitbinary(node) end function end class
you can call using :
sub main() dim whereclause expression(of func(of foo, boolean)) = function(f foo) f.id = 1 dim s string = wherevisitor.stringify(whereclause) console.writeline(s) end sub
the visitor
has modified better fit needs have start point implement want.