Is there a way to Deserialize Expressions in C#, I would like to store Expressions in a Database and load them at run time.
Serialization is to store tree in a file so that it can be later restored. The structure of tree must be maintained. Deserialization is reading tree back from file.
Serialize and Deserialize Binary Tree. Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.
Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.
There are 3 main binary tree traversal methods: pre-order, in-order, and post-order. We can serialize and deserialize a binary tree with a combination of two methods, e.g., pre-order and in-order methods.
I continued work on the library that was mentioned by Serializing and Deserializing Expression Trees in C#
It looks like the project was abandoned (2008) but I did some work on it and now it works with .NET 4.0 and Silverlight. I made bug fixes to their code and also made it more DAL-independent.
http://expressiontree.codeplex.com/
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With