gpt4 book ai didi

c# - ODAC 11.2 版本 4 (11.2.0.3.0) 抛出 "Oracle 11.2.0.2.0 does not support APPLY"异常

转载 作者:太空狗 更新时间:2023-10-29 19:48:05 24 4
gpt4 key购买 nike

我正在使用 Entity Framework 和 oracle 刚刚发布的新 ODAC。

我的问题是我的一些在以前的测试版中有效的查询在这个新版本中停止了。

这是一个例子:

IQueryable<SYS_PERFIL> query1 = m.DBContext.SYS_PERFIL.Where(T => T.SYS_UTILIZADOR.Where(TT => TT.ACTIVO == 1).Count() > 0);

IQueryable<SYS_PERFIL> query2 = m.DBContext.SYS_PERFIL.Where(T => T.SYS_UTILIZADOR.FirstOrDefault(TT => TT.ACTIVO == 1) != null);

string test1Query = ((System.Data.Objects.ObjectQuery)query1).ToTraceString();

string test2Query = ((System.Data.Objects.ObjectQuery)query2).ToTraceString();

var test1 = query1.ToList();

var test2 = query2.ToList();

当 test1 返回当前结果时,test2 抛出 oracle 异常“ORA-00905:缺少关键字”,消息为:“Oracle 11.2.0.2.0 不支持 APPLY”。

我不想重新测试我所有的方法。有没有办法告诉 EF 不要使用 apply?

以下是 EF 生成的查询:

测试1查询:

SELECT "Project1"."PERFIL_ID" AS "PERFIL_ID" FROM ( SELECT "Extent1"."PERFIL_ID" AS PERFIL_ID", (SELECT COUNT(1) AS "A1" FROM "SMI2012"."SYS_UTILIZADOR" "Extent2" WHERE (("Extent1"."PERFIL_ID" = "Extent2"."PERFIL_ID") AND (1 = "Extent2"."ACTIVO"))) AS "C1"
FROM "SMI2012"."SYS_PERFIL" "Extent1") "Project1" WHERE ("Project1"."C1" > 0)

测试2查询:

SELECT "Extent1"."PERFIL_ID" AS "PERFIL_ID" FROM  "SMI2012"."SYS_PERFIL" "Extent1" CROSS APPLY  (SELECT "Extent2"."PERFIL_ID" AS "PERFIL_ID", "Extent2"."ACTIVO" AS "ACTIVO", "Extent2"."USER_ID" AS "USER_ID" FROM "SMI2012"."SYS_UTILIZADOR" "Extent2" WHERE (("Extent1"."PERFIL_ID" = "Extent2"."PERFIL_ID") AND (1 = "Extent2"."ACTIVO")) AND (ROWNUM <= (1) ) ) "Element1" WHERE ("Element1"."USER_ID" IS NOT NULL)

提前致谢。

最佳答案

Telerik OpenAccess ORM 不使用 APPLY 语句。我在嵌套组查询中遇到了同样的问题。当我构建 OA 模型时,查询运行得很好!

关于c# - ODAC 11.2 版本 4 (11.2.0.3.0) 抛出 "Oracle 11.2.0.2.0 does not support APPLY"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8892515/

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