是否有可能来评估包含有效LINQ动态/运行时的字符串? [英] Is it possible to evaluate a string containing valid LINQ dynamically / at runtime?

查看:190
本文介绍了是否有可能来评估包含有效LINQ动态/运行时的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其基本思想是把一个字符串,并评估其对XML文件(或任何LINQed提供商)

我发现这个<一href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx">LINQ动态查询库的。刚刚有了一个粗略的看一下这是在下载包一个单页的文档。这似乎是增加扩展方法参数化的LINQ查询的部分。有谁知道,如果这样做动态评价?

有没有办法只是做(假设有一些方法来种子类将数据从XML文件)?

  ClassFromWishfulThinking.Evaluate(sLinqQuery);
 

解决方案

这必须是可能的,因为 Linqpad 做它!

纵观它是如何工作页面有点头脑弯,我不相信这是你会想要做生产code,除非你真的无法避免。

没有,只是你想要做什么框架方法,我可以说,因为.NET是如何工作的,随着信心相当高的程度。您可以使用 CSHARP codeprovider 为LinqPad一样。

您也许能够改变的LINQ动态查询库去做你所需要的。

The basic idea is to take a string and evaluate it against an XML File (or any LINQed provider)

I found this LINQ Dynamic Query Library. Just had a cursory glance at the documentation which is a single page in the download bundle. This seems to be adding extension methods to parameterize parts of the LINQ Query. Does anyone know if this does dynamic evaluation?

Is there any way to just do (assuming there is some way to seed the class with the Data from the XML File) ?

ClassFromWishfulThinking.Evaluate(sLinqQuery);

解决方案

It must be possible because Linqpad does it!

Looking at the how it works page is a bit mind bending, and I'm not sure this is something you would want to do with production code unless you really couldn't avoid it.

There is no framework method that just does what you want, I can say that with a fairly high degree of confidence because of how .net works. You have to call the compiler using the csharpcodeprovider as LinqPad does.

You might be able to change the Linq Dynamic Query Library to do what you need.

这篇关于是否有可能来评估包含有效LINQ动态/运行时的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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