简体   繁体   English

在C#中序列化和反序列化表达式树

[英]Serializing and Deserializing Expression Trees in C#

有没有办法在C#中反序列化表达式,我想将表达式存储在数据库中并在运行时加载它们。

I continued work on the library that was mentioned by Serializing and Deserializing Expression Trees in C# 我继续研究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. 看起来该项目已被放弃(2008),但我做了一些工作,现在它适用于.NET 4.0和Silverlight。 I made bug fixes to their code and also made it more DAL-independent. 我对他们的代码进行了错误修复,并使其更加独立于DAL。

http://expressiontree.codeplex.com/ http://expressiontree.codeplex.com/

Other option is the Expression Tree Serialization project on code.msdn.com - would appear to be more what is needed here? 其他选项是code.msdn.com上的表达式树序列化项目 - 看起来更像是需要什么?

UPD: Now http://archive.msdn.microsoft.com/exprserialization UPD:现在http://archive.msdn.microsoft.com/exprserialization

There's an project on GitHub/Nuget called MetaLinq that aims to make working with expression tress more easy. 在GitHub / Nuget上有一个名为MetaLinq的项目,旨在使表达tress的工作变得更加容易。

It converts between normal Expressions and 'EditableExpressions' which are mutable and fully Serializable, so can be used with Json, Xml, Binary etc. 它在正常的表达式和'EditableExpressions'之间进行转换,这些表达式是可变的并且完全可序列化,因此可以与Json,Xml,Binary等一起使用。

Also check this blog post for more info. 另请查看此博客文章以获取更多信息。

have a look at my new library Serialize.Linq . 看看我的新库Serialize.Linq It serializes linq expressions to json, xml and binary. 它将linq表达式序列化为json,xml和binary。

Not in full; 不完整; however, the Dynamic LINQ sample may help a bit. 但是, 动态LINQ示例可能会有所帮助。 You can certainly serialize an expression to a string (to an extent - generics look a bit screwy), but there is no inbuilt parser. 你当然可以将一个表达式序列化为一个字符串(在某种程度上 - 泛型看起来有点棘手),但是没有内置的解析器。

WCF RIA Services allows for serializing IQuerayble<T> WCF RIA Services允许序列化IQuerayble<T>

WCF RIA Services Part 3 – Updating Data WCF RIA服务第3部分 - 更新数据

I was working on a project for serializing expressions. 我正在开发一个序列化表达式的项目。 It's OK and you can use it. 没关系,你可以使用它。 http://www.codeproject.com/Articles/851187/ServicePredicateBuilder-for-creating-Serializable http://www.codeproject.com/Articles/851187/ServicePredicateBuilder-for-creating-Serializable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM