Parsing a string C# LINQ expression

前端 未结 2 680
醉酒成梦
醉酒成梦 2020-12-01 12:37

I\'m trying to do some really dynamic querying here - preferably without invoking the compiler at runtime though.

I have a string containing a LINQ expression, e.g.<

2条回答
  •  旧时难觅i
    2020-12-01 13:31

    Going from a "magic string" to code objects always involves some sort of parsing. In this case, it might be best to work with the EditableExpression library (available free from Google Code). Take your string, and format it to look like the result of serializing a series of EditableExpressions. Then, simply deserialize it and convert to an expression tree.

提交回复
热议问题