3

我在基於實體框架的數據訪問中使用實體框架來定位多個數據庫。實體框架左外連接和組拋入:ORA-00907:右右括號

我們是一個使用Entity Framework工作了兩年的團隊,所生成的代碼與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: 

任何幫助將不勝感激,謝謝 提前。

+1

請告訴我們,生成錯誤 – 2012-04-22 08:24:57

+0

+1請出示通話,請求或SQL語句在SQL產生錯誤 – Regfor 2012-04-22 09:32:22

+0

它是一個linq查詢,而不是sql語句。並且它與sql server完美配合 – 2012-04-22 12:39:27

回答

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();