c# - SqlFunctions 和 EntityFunctions 有什么区别?

标签 c# entity-framework

有什么区别? 都是在获取数据存入内存之前在sql端执行函数吗?

附言: 两者都用于 linq to entities。

最佳答案

如文档所述EntityFunctions

Provides common language runtime (CLR) methods that expose conceptual model canonical functions in LINQ to Entities queries. For information about canonical functions, see Canonical Functions (Entity SQL).

哪里Canonical functions

are supported by all data providers, and can be used by all querying technologies. Canonical functions cannot be extended by a provider. These canonical functions will be translated to the corresponding data source functionality for the provider. This allows for function invocations expressed in a common form across data sources.

SQLFunctions

Provides common language runtime (CLR) methods that call functions in the database in LINQ to Entities queries.

因此,虽然两组函数都被翻译成原生 SQL,但 SQLFunctions 是特定于 SQL Server 的,而 EntityFunctions 不是。

关于c# - SqlFunctions 和 EntityFunctions 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15637317/

相关文章:

c# - 使用 Autofac 的异步 ASP.NET Web API 方法中的 ObjectDisposeException

c# - 在 MVC 中清除 View 引擎会破坏站点地图面包屑样式

c# - NHibernate:二级缓存过期

c# - 在 Google Spreadsheet API 中添加一个简单的标题行

c# - 我应该如何处理引用实体的持久性?

c# - Entity Framework - 代码优先 - 数据注释 - 不必要的外键列

c# - 所有获取数据库对象的 linq 都应该用 try catch 包围吗?

c# - 使用给定的用户名在远程机器上安装 Windows 服务

c# - 向我的应用程序添加服务层

c# - Entity Framework 0..1 到 0 的关系