实体框架左外连接和分组:ORA-00907:缺少右括号
Posted
技术标签:
【中文标题】实体框架左外连接和分组:ORA-00907:缺少右括号【英文标题】:Entity framework Left Outer Joins and Group into throws : ORA-00907: missing right parenthesis 【发布时间】:2012-04-22 07:40:48 【问题描述】:我在基于实体框架的数据访问中使用实体框架来定位多个数据库。
我们是一个使用 Entity Framework 的团队,已经 2 年了,生成的代码与 sql server 2008 完美配合。现在,我们在将数据库迁移到 Oracle 11 express r2g2 后测试相同的代码,以及所有说明使左外连接或组进入显示此调用堆栈的选择抛出异常:
System.Data.EntityCommandExecutionException was unhandled by user code
Message=An error occurred while executing the command definition. See the inner exception for details.
Source=System.Data.Entity
StackTrace:
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.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Futura.BusinessLogic.Services.DemandeHospitalisationServices.DemandeHospitalisationService.GetMedecinList() in C:\Work\FuturaSmartDesign\Futura.BusinessLogic\Services\DemandeHospitalisationServices\DemandeHospitalisationService.cs:line 87
at GetMedecinList(DomainService , Object[] )
at System.ServiceModel.DomainServices.Server.ReflectionDomainServiceDescriptionProvider.ReflectionDomainOperationEntry.Invoke(DomainService domainService, Object[] parameters)
at System.ServiceModel.DomainServices.Server.DomainOperationEntry.Invoke(DomainService domainService, Object[] parameters, Int32& totalCount)
at System.ServiceModel.DomainServices.Server.DomainService.Query(QueryDescription queryDescription, IEnumerable`1& validationErrors, Int32& totalCount)
InnerException: Oracle.DataAccess.Client.OracleException
Message=ORA-00907: missing right parenthesis
Source=Oracle Data Provider for .NET
ErrorCode=-2147467259
DataSource=Calys
Number=907
Procedure=""
StackTrace:
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Exception innerException)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck, Exception innerException)
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
at Oracle.DataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
InnerException:
Message=Oracle 11.2.0.2.0 ne prend pas en charge APPLY
InnerException:
任何帮助将不胜感激, 提前致谢。
【问题讨论】:
请告诉我们产生错误的SQL +1 请显示产生错误的调用、请求或 SQL 语句 这是一个 linq 查询,而不是 sql 语句。它与 sql server 完美配合 @a.boussema:你找到解决这个问题的方法了吗? 【参考方案1】:这是由于实体框架生成的代码:CROSS/OUTER APPLY;甲骨文不支持。 这是在 Connect 上报告的, https://connect.microsoft.com/VisualStudio/feedback/details/739458/linq-query-whene-used-with-oracle-11-g2-getting-ora-00907-missing-right-parenthesis
任何解决方法都将在 MS Connect 平台上得到赞赏
【讨论】:
【参考方案2】:当我的 EF 查询有太多“包含”时,我在 EF 5 和 Oracle 11g 中遇到了这个错误。在我的情况下 7 ".Include" 会导致此错误。
var myEntity = __DbContext.Get<MyEntity>()
.Include("Property1")
.Include("Property2")
.Include("Property3")
.Include("Property4")
.Include("RelatedEntities.Property1")
.Include("RelatedEntities.Property2")
.Include("RelatedEntities.Property3")
.First(c => c.Id == id);
我将其更改为进行两个查询来获取我的数据:
var myEntity = __DbContext.Get<MyEntity>()
.Include("Property1")
.Include("Property2")
.Include("Property3")
.Include("Property4")
.First(c => c.Id == id);
myEntity.RelatedEntities = __DbContext.Get<RelatedEntity>()
.Include("Property1")
.Include("Property2")
.Include("Property3")
.Where(re => re.MyEntityId == myEntity.Id)
.ToList();
【讨论】:
以上是关于实体框架左外连接和分组:ORA-00907:缺少右括号的主要内容,如果未能解决你的问题,请参考以下文章
SQL 错误:ORA-00907:缺少右括号 00907。00000 -“缺少右括号”
错误报告 - ORA-00907: 缺少右括号 00907. 00000 - “缺少右括号