如何创建一个允许我输入LINQ表达式的控制台应用程序,我的程序将执行它们?

时间:2022-06-18 02:12:16

How can I write a console application that prompts me and lets me enter LINQ expressions and it will spit out the results of that LINQ query?

如何编写一个控制台应用程序,提示我并让我输入LINQ表达式,它会吐出LINQ查询的结果?

What would be the easiest way to parse/evaluate a incoming string as a LINQ expression?

将传入字符串解析/评估为LINQ表达式的最简单方法是什么?

3 个解决方案

#1


Console app is to awkward to use for thousands of reasons. Try LinqPad

控制台应用程序由于数千个原因而难以使用。试试LinqPad

#2


use Dynamic LINQ query library , see this

使用Dynamic LINQ查询库,请参阅此内容

#3


I wrote LinqFilter for something similar to this purpose. It does no parsing of LINQ query expressions on its own, but rather sends the code off to the C# v3.5 compiler via Microsoft.CSharp.CSharpCodeProvider to compile into a dynamic assembly and executes the compiled method containing the query. If you were looking for a more interactive approach to designing LINQ queries over databases, LinqPad would be the better tool.

我为类似的目的编写了LinqFilter。它本身不解析LINQ查询表达式,而是通过Microsoft.CSharp.CSharpCodeProvider将代码发送到C#v3.5编译器,以编译成动态程序集并执行包含查询的编译方法。如果您正在寻找一种更加交互式的方法来设计数据库上的LINQ查询,那么LinqPad将是更好的工具。

#1


Console app is to awkward to use for thousands of reasons. Try LinqPad

控制台应用程序由于数千个原因而难以使用。试试LinqPad

#2


use Dynamic LINQ query library , see this

使用Dynamic LINQ查询库,请参阅此内容

#3


I wrote LinqFilter for something similar to this purpose. It does no parsing of LINQ query expressions on its own, but rather sends the code off to the C# v3.5 compiler via Microsoft.CSharp.CSharpCodeProvider to compile into a dynamic assembly and executes the compiled method containing the query. If you were looking for a more interactive approach to designing LINQ queries over databases, LinqPad would be the better tool.

我为类似的目的编写了LinqFilter。它本身不解析LINQ查询表达式,而是通过Microsoft.CSharp.CSharpCodeProvider将代码发送到C#v3.5编译器,以编译成动态程序集并执行包含查询的编译方法。如果您正在寻找一种更加交互式的方法来设计数据库上的LINQ查询,那么LinqPad将是更好的工具。