Serializing and Deserializing Expression Trees in C#

Viewed 44838

Is there a way to Deserialize Expressions in C#, I would like to store Expressions in a Database and load them at run time.

7 Answers

There's an project on GitHub/Nuget called MetaLinq that aims to make working with expression tress more easy.

It converts between normal Expressions and 'EditableExpressions' which are mutable and fully Serializable, so can be used with Json, Xml, Binary etc.

Also check this blog post for more info.

Not in full; however, the Dynamic LINQ sample may help a bit. You can certainly serialize an expression to a string (to an extent - generics look a bit screwy), but there is no inbuilt parser.

Related