我最近更新到asp.net core 2.0。由于使用Include方法升级所有Linq查询失败,因此无法正确转换为SQL。
例如:
var entities = helpTopicRepository.Entities.Include(x => x.HelpArticles).FirstOrDefault(t => topicIds.Any(a => a == t.Id));
被翻译为:
SELECT x.HelpArticles.ART_ID,
x.HelpArticles.AVAILABLE,
x.HelpArticles.CONTENT,
x.HelpArticles.DISPLAYORDER,
x.HelpArticles.HELPFULNO,
x.HelpArticles.HELPFULYES,
x.HelpArticles.KEYWORDS,
x.HelpArticles.TITLE,
x.HelpArticles.TOPICID
FROM HELPARTICLE x.HelpArticles
导致以下错误:
Devart.Data.Oracle.OracleException (0x80004005): ORA-00933: SQL
命令未在Devart.Data.Oracle.ay.b()处正确结束 Devart.Data.Oracle.am.f()在Devart.Data.Oracle.am.e()处于 Devart.Data.Oracle.c5.a(am A_0,Int32 A_1)at Devart.Data.Oracle.c5.a(Int32 A_0,bg A_1)at Devart.Data.Oracle.OracleCommand.InternalExecute(的CommandBehavior 行为,IDisposable一次性,Int32 startRecord,Int32 maxRecords, 布尔非查询) Devart.Common.DbCommandBase.ExecuteDbDataReader(的CommandBehavior 行为,布尔非查询) Devart.Data.Oracle.Entity.ai.a(CommandBehavior A_0)at Devart.Common.Entity.cj.d(CommandBehavior A_0)at Devart.Data.Oracle.Entity.ai.b(CommandBehavior A_0)at System.Data.Common.DbCommand.ExecuteReader()at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection,DbCommandMethod executeMethod,IReadOnlyDictionary
2 parameterValues) at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary
2 parameterValues)at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.BufferlessMoveNext(Boolean buffer) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable
1.Enumerator.MoveNext() 在 Microsoft.EntityFrameworkCore.Query.Internal.QueryBuffer.IncludeCollection(的Int32 includeId,INAVigation navigation,INavigation inverseNavigation, IEntityType targetEntityType,IClrCollectionAccessor clrCollectionAccessor,IClrPropertySetter inverseClrPropertySetter, 布尔跟踪,对象实体,Func1 relatedEntitiesFactory) at lambda_method(Closure , QueryContext , Client , Object[] ) at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler._Include[TEntity](QueryContext queryContext, TEntity entity, Object[] included, Action
3 fixup)at lambda_method(Closure,Client)at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable
1 source) 在lambda_method(Closure,QueryContext)处 Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler<> c__DisplayClass17_0`1.b__0(QueryContext qc)ORA-00933:SQL命令未正确结束
我正在使用Devart dotconnect连接到Oracle数据库。
答案 0 :(得分:1)
由于你的陈述:
var entities = helpTopicRepository.Entities.Include(x => x.HelpArticles).FirstOrDefault(t => topicIds.Any(a => a == t.Id));
假设topicIds
是一个列表,这是一个修复:
var entities = helpTopicRepository.Entities
.Include(x => x.HelpArticles)
.Where(t => topicIds.Contains(t.Id))
.FirstOrDefault();
答案 1 :(得分:0)
修复了在EF Core 2中使用多个.Include()的错误。期待dotConnect for Oracle的下一个公共构建。