.NET 9 - Devart.Data.Oracle.EfCore - Discriminator issue with include
Hello Devart,
When using discriminators in EF Core and then including navigational properties which aren't available on all discriminated types, only on specific derived types:
- var result = await ctx.Vehicles
- .Include(_ => ((Car)_).PossibleEngineTypes) // this line is problematic in .NET 9
- .ToListAsync();
This now throws the following exception since the .NET 9 upgrade:
- System.InvalidOperationException: 'Unexpected ProjectionExpression implementation.'
- at Devart.Common.Entity.EntityExpressionFactory.Alias(SqlExpression argument, String alias)
- at Devart.Data.Oracle.Entity.AliasRenamer.W73XitM5qM(ProjectionExpression )
- at Devart.Data.Oracle.Entity.AliasRenamer.Rename()
- at Devart.Data.Oracle.Entity.AliasRenamerVisitor.VisitExtension(Expression node)
- at xKXfW2OyYoQIcN80hsY.V1HIAgerrF(Object , Expression , xKXfW2OyYoQIcN80hsY )
- at Devart.Data.Oracle.Entity.AliasRenamerVisitor.VisitExtension(Expression node)
- at xKXfW2OyYoQIcN80hsY.V1HIAgerrF(Object , Expression , xKXfW2OyYoQIcN80hsY )
- at Devart.Data.Oracle.Entity.OracleQueryTranslationPostprocessor.Process(Expression query)
- at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutorExpression[TResult](Expression query)
- at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
- at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
- at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
- at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass11_0`1.<ExecuteCore>b__0()
- at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
- at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteCore[TResult](Expression query, Boolean async, CancellationToken cancellationToken)
- at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
- at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
- at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken)
- at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.IncludableQueryable`2.GetAsyncEnumerator(CancellationToken cancellationToken)
- at System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()
- at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.<ToListAsync>d__67`1.MoveNext()
- at Program.<<Main>$>d__0.MoveNext() in Program.cs:line 13
- at Program.<Main>(String[] args)
This is something that was working in .NET 8 and Devart 10.3.105.8.
In the attachments you can find a solution with both a working (.NET 8 ) and broken (.NET 9) implementation.
Thanks.