实体框架左外连接和组到抛出:ORA-00907:缺少右括号(Entity framework Lef

2019-09-16 16:40发布

我正在使用基于实体框架数据访问实体框架的目标多个数据库。

我们是一个团队,实体框架现在的工作,2年,并且代码制作的作品完美地与SQL Server 2008。现在,我们正在迁移的数据库的Oracle 11明示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:

任何帮助将提前赞赏,感谢。

Answer 1:

这是由于由实体框架生成的代码:CROSS / OUTER APPLY; 甲骨文不支持。 这是此报告的连接, https://connect.microsoft.com/VisualStudio/feedback/details/739458/linq-query-whene-used-with-oracle-11-g2-getting-ora-00907-missing-right -插入语

任何解决方法将在MS Connect平台可以理解



Answer 2:

我有这个错误与EF 5和Oracle 11g时,我的EF查询有太多的“包含”。 在我的情况下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(); 


文章来源: Entity framework Left Outer Joins and Group into throws : ORA-00907: missing right parenthesis