Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 实体框架核心-Take(1),Single(),First()。。。无法使用Oracle提供程序(ORA-00933:SQL命令未正确结束)_C#_Oracle_Entity Framework_Entity Framework Core_Oracle Manageddataaccess - Fatal编程技术网

C# 实体框架核心-Take(1),Single(),First()。。。无法使用Oracle提供程序(ORA-00933:SQL命令未正确结束)

C# 实体框架核心-Take(1),Single(),First()。。。无法使用Oracle提供程序(ORA-00933:SQL命令未正确结束),c#,oracle,entity-framework,entity-framework-core,oracle-manageddataaccess,C#,Oracle,Entity Framework,Entity Framework Core,Oracle Manageddataaccess,我在oracle数据库中使用ef core(2.2.4) oracleProvider:Oracle.EntityFrameworkCore(2.18.0-beta3) 此代码: IQueryable<KeyInfo> queryable = context .KeyInfos .Where(x => x.MobileNumber == "989191111111") .Take(1

我在oracle数据库中使用ef core(2.2.4)

oracleProvider:Oracle.EntityFrameworkCore(2.18.0-beta3)

此代码:

IQueryable<KeyInfo> queryable = context
                .KeyInfos
                .Where(x => x.MobileNumber == "989191111111")
                .Take(1);
运行查询时会出现以下错误:

ORA-00933: SQL command not properly ended
00933. 00000 -  "SQL command not properly ended"
*Cause:    
*Action:
Error at Line: 4 Column: 1
有办法解决吗?正确的方法是使用

和rownum=1

不是

仅获取前1行


而且.ToList()可以与IQueryable配合使用

显然,您的目标是一个较旧的Oracle数据库,它不支持较新的
仅获取前N行
SQL构造

为了获得较旧的基于
ROWNUM
的SQL转换,您应该使用
UseOracle
方法和
UseOracleSQLCompatibility
扩展方法的可选
Action或acleoptionAction
参数,值为“11”(当前唯一支持的值是“11”和“12”):


您是否尝试过使用.First()?@PauloCampez是的,因此尝试了FirstOrDefault,但没有效果Oracle 10有任何支持吗?我试图使Entity Framework Core与Oracle 10一起工作,但没有成功。@EdsonRodrigues根据页面,Oracle支持的数据库引擎。EntityFrameworkCore是Oracle DB 11.2以后的版本。该页面还显示了DevArt支持Oracle DB 9.2.0.4及以后版本的提供商,但它是付费产品。
ORA-00933: SQL command not properly ended
00933. 00000 -  "SQL command not properly ended"
*Cause:    
*Action:
Error at Line: 4 Column: 1
.UseOracle(connection_string, options => options
    .UseOracleSQLCompatibility("11"))