Lambda Expression Tree Parsing

前端 未结 4 1319
慢半拍i
慢半拍i 2020-12-28 18:51

I am trying to use Lambda Expressions in a project to map to a third party query API. So, I\'m parsing the Expression tree by hand.

If I pass in a lambda expression

4条回答
  •  暖寄归人
    2020-12-28 19:10

    To get the actual value, you need to apply the logic of the expression tree to whatever context you've got.

    The whole point of expression trees is that they represent the logic as data rather than evaluating the expression. You'll need to work out what the lambda expression truly means. That may mean evaluating some parts of it against local data - you'll need to decide that for yourself. Expression trees are very powerful, but it's not a simple matter to parse and use them. (Ask anyone who's written a LINQ provider... Frans Bouma has bemoaned the difficulties several times.)

提交回复
热议问题