且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Func键<>>表达℃之间的差异;和Func键<>

更新时间:2021-12-14 07:58:53

使用表达式来; T&GT; 你明确地创建一个 表达式树的 - 这意味着你可以处理,使得代码了查询,好像它是数据

Using Expression<T> you are explicitly creating an expression tree - this means that you can deal with the code that makes up the query as if it were data.

这样做的原因是,LINQ提供(如LINQ到SQL例如)检查查询本身来确定的***方式C#的表达式转换成T-SQL查询。由于表达式树可以让你看看代码为数据提供者能够做到这一点。

The reason for this is that LINQ providers (like LINQ to SQL for example) inspect the query itself to determine the best way to translate the C# expressions into a T-SQL query. Since an expression tree lets you look at the code as data the provider is able to do this.