oracle - 有时,使用 Entity Framework 查询 Oracle DB 时会出现错误 "ORA-00933",但是当我重新启动 webapp 时,它可以工作

标签 oracle entity-framework

我已经将 Entity Framework 5 用于基于 Web 的应用程序的 Oralce 数据库。有时(很少发生),会出现错误“ORA-00933”,但是当我重新启动 web 应用程序时,它又开始工作了。
这是日志:

System.Data.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> Oracle.ManagedDataAccess.Client.OracleException: ORA-00933: SQL command not properly ended at OracleInternal.ServiceObjects.OracleCommandImpl.VerifyExecution(OracleConnectionImpl connectionImpl, Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone) at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[] scnForExecution, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, Int64& internalInitialLOBFS, OracleException& exceptionForArrayBindDML, Boolean isDescribeOnly, Boolean isFromEF) at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) --- End of inner exception stack trace --- at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues) at System.Data.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) at System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source) at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
at MOS.DAO.HisTreatment.HisTreatmentGet.GetById(Int64 id, HisTreatmentSO search)



这是代码“HisTreatmentGet.GetById”:
HIS_TREATMENT result = null;
try
{
    bool valid = true;
    using (var ctx = new AppContext())
    {
        var query = ctx.HIS_TREATMENT.AsQueryable().Where(p => p.ID == id);
        ...
        result = query.SingleOrDefault();
    }
}
catch (Exception ex)
{
    ....
}
return result;

我试过在谷歌上搜索,但没有解决方案。任何人都可以给我建议吗?

最佳答案

Oracle 的 Entity Framework 提供程序中存在错误。

Seems like the Oracle.ManagedDataAccess.EntityFramework.SqlGen.SqlSelectStatement.Top_s is the culprit that gets borrowed by a parallel query. This should either be thread static (quick hack) or moved to some contextual state (proper fix, e.g. to SqlGenerator).



https://community.oracle.com/thread/3728543

Oracle 支持部门没有答复。话虽如此,nuget 包有一个新版本:12.2.110 .您可以尝试一下并检查问题是否已解决。

关于oracle - 有时,使用 Entity Framework 查询 Oracle DB 时会出现错误 "ORA-00933",但是当我重新启动 webapp 时,它可以工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43554591/

相关文章:

c# - 从多个模型解析相同的表名

sql-server - 无法找到任一列 "dbo"或用户定义函数无法找到任一列

javascript - 是否有任何 JavaScript 方法可以复制 Oracle 的 ADD_MONTH() 功能

sql - 如何在子查询中使用别名?

c# - 如何让visual studio在做集成测试时运行一次TestInitialize?

c# - Linq、lambda 和@

.net - 如何从 Entity Framework 中删除关系

sql - 多次插入相同的数据

oracle - PL/SQL 中的 BEGIN - END block 原子事务

sql - 如何将日期值插入表中