Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serializing and Deserializing Expression Trees in C#

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

like image 209
Alexandre Brisebois Avatar asked Oct 20 '08 10:10

Alexandre Brisebois


People also ask

What is serializing a tree?

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.

What is serializing a binary tree?

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.

What is serialize and deserialize in C?

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.

What are the Traversals required to serialize and deserialize a binary tree?

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.


2 Answers

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/

like image 194
T. Webster Avatar answered Oct 23 '22 23:10

T. Webster


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.

like image 42
Pop Catalin Avatar answered Oct 23 '22 22:10

Pop Catalin