是否可以通过通讯链接序列化和传输表达式(如LINQ)? [英] Can I serialize and transmit an Expression (as in LINQ) over a comms link?

查看:67
本文介绍了是否可以通过通讯链接序列化和传输表达式(如LINQ)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想象一下,有一个服务器进程具有执行LINQ查询,枚举结果并将其发送回所需的所有类型.

Imagine there is a server process that has all of the types needed to excute a LINQ query, enumerate results and send them back.

现在想象一下,有一个客户端具有一个Expression(将在LINQ Provider的CreateQuery方法中看到)并希望对其进行序列化,发送到服务器并等待结果返回之前.

Now imagine there is a client that has an Expression (as will be seen in the LINQ Provider's CreateQuery method) and wants to serialize this, send to server and wait for results before returning them.

这里的情况是服务器具有我们需要查询的所有内存中集合,并且还具有所有类型等.

The scenario here is that the server has all of the in-memory collections we need to query against and has all of the types etc too.

为什么没有对此的支持?似乎并没有真正的序列化表达式树的支持-网上有一些尝试-但它们似乎有错误/alpha级.

Why is there no support for this? it seems there is no real support for serializing Expression trees - a few attempts are on the web - but they appear buggy/alpha grade.

例如,假设服务器具有一个简单的Dictionary< K,V>.该词典具有一个字符串键,而V是一个IList< string> ;,因此包含多个列表,每个列表都带有一个名称".

Imagine for example that the server has a simple Dictionary<K,V> that dictionary has a string key and V is an IList<string>, so contains multiple lists each with a "name".

想象一下,我们向该服务器发送一条消息,其中包含a)我们要查询的列表的名称和b)代表查询本身的LINQ表达式-在此示例中,服务器将1)标识要从中使用的列表名称,然后2)使用 清单,如查询中所示,然后3)将查询反序列化为表达式,然后枚举结果...

Imagine we send a message to this server that contains a) The name of the list we want to query and b) the LINQ Expression representing the query itself - well in this example the server would 1) Identify the list to use from the name and then 2) use that list as in the query and 3) Deserialize the query into an Expression and then enum the results...

在这种情况下,为什么我们不能对表达式进行序列化和序列化以让我们做类似的事情?

In such a setting why can we not serialize and serialize the expression to let us do something like this?

Cap'n

推荐答案

一个非常有趣的问题...我想知道是否也有一个好方法.

Very interesting question...I'd like to know if there is a good way to do this too.

我发现周围漂浮着东西,但老实说我根本没有测试它.通常看来,人们确实很希望能够做到这一点,但这有点要求CLR能够序列化匿名方法...

I found thing floating around, but honestly I didn't test it at all. It generally seems like people would really like to be able to do this, but it kinda requires the CLR to be able to serialize anonymous methods...


这篇关于是否可以通过通讯链接序列化和传输表达式(如LINQ)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆