gpt4 book ai didi

c# - Entity Framework 如何知道如何为特定后端生成 SQL 并且可以更改它?可怕的申请问题

转载 作者:行者123 更新时间:2023-11-30 18:31:25 26 4
gpt4 key购买 nike

我有一个使用 Entity Framework(我认为是 4.1)的应用程序。我目前正在使用 Oracle ODAC 112030 32 位。我有两台机器,一台使用 .Net Framework 4.0,另一台使用 4.5 版(4.0 的替代品)。当我运行我的 Web 应用程序并在 4.0 机器上执行特定的 Linq-To-Entities 查询时,查询运行正常,但是当我运行 4.5 机器时,查询失败并出现 Oracle 错误 {"ORA-00907: missing right括号"} 内部异常{"Oracle 10.2.0.4.0 不支持APPLY"}

我的问题是,有没有办法告诉 EF 不要使用 APPLY?如果没有,是否有针对单个 Linq 查询中的 FirstOrDefault() 的解决方法?

Microsoft 列出了 EF 关于 APPLY 的已知问题 EF Known Issues 4.5

Blurb 来自上面的链接

Targeting the Correct SQL Server Version The Entity Framework targets the Transact-SQL query based on the SQL Server version that is specified in the ProviderManifestToken attribute of the Schema element in the storage model (.ssdl) file. This version might differ from the version of the actual SQL Server you are connected to. For example, if you are using SQL Server 2005, but your ProviderManifestToken attribute is set to 2008, the generated Transact-SQL query might not execute on the server. For example, a query that uses the new date time types that were introduced in SQL Server 2008 will not execute on earlier versions of the SQL Server. If you are using SQL Server 2005, but your ProviderManifestToken attribute is set to 2000, the generated Transact-SQL query might be less optimized, or you might get an exception that says that the query is not supported. For more information, see the CROSS and OUTER APPLY Operators section, earlier in this topic. Certain database behaviors depend on the compatibility level set to the database. If your ProviderManifestToken attribute is set to 2005 and your SQL Server version is 2005, but the compatibility level of a database is set to "80" (SQL Server 2000), the generated Transact-SQL will be targeting SQL Server 2005, but might not execute as expected due to the compatibility level setting. For example, you might lose ordering information if a column name in the ORDER BY list matches a column name in the selector.

在我的例子中,我只看到“Provider="Oracle.DataAccess.Client"ProviderManifestToken="10.2",因为我使用的是 Oracle。

最佳答案

Entity Framework 现已在 https://github.com/aspnet/EntityFramework 开源,这样您就可以阅读代码来回答您自己的问题。

关于c# - Entity Framework 如何知道如何为特定后端生成 SQL 并且可以更改它?可怕的申请问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20206265/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com