Unexpected SqlParameterExpression implementation when using Oracle spatial functions in EF Core 8

Unexpected SqlParameterExpression implementation when using Oracle spatial functions in EF Core 8

We are planning to upgrade EF Core 6 to EF Core 8 along with upgrade from .NET 6 to .NET 8. We frequently use Oracle spatial functions: "SDO_RELATE" and "SDO_WITHIN_DISTANCE", which unfortunately do not have built-in support in dotConnect for Oracle according to my question: https://support.devart.com/portal/en/community/topic/built-in-oracle-spatial-functions-for-ef-core
However we were able to implement that support ourselves using EF Core modelBuilder.HasDbFunction() method:
  1. [DbFunction("<namespace>", "SDO_RELATE")]
  2. public static string SdoRelate(Geometry geometry1, Geometry geometry2, string param)
  3. {
  4. throw NotSupportedOutsideLinq();
  5. }

  6. [DbFunction("<namespace>", "SDO_WITHIN_DISTANCE")]
  7. public static string SdoWithinDistance(Geometry geometry1, Geometry geometry2, string param)
  8. {
  9. throw NotSupportedOutsideLinq();
  10. }

  11. internal static void AddDbFunctions(ModelBuilder modelBuilder)
  12. {
  13. modelBuilder.HasDbFunction(typeof(OracleSpatialFunctions).GetMethod(
  14. nameof(OracleSpatialFunctions.SdoRelate), new[] { typeof(Geometry), typeof(Geometry), typeof(string) }))
  15. .HasName("SDO_RELATE");

  16. modelBuilder.HasDbFunction(typeof(OracleSpatialFunctions).GetMethod(
  17. nameof(OracleSpatialFunctions.SdoWithinDistance), new[] { typeof(Geometry), typeof(Geometry), typeof(string) }))
  18. .HasName("SDO_WITHIN_DISTANCE");
  19. }
and then later we can query database using such query:
  1. var query = await context.DATABASE_TABLE
  2. .Where(x =>
  3. OracleSpatialFunctions.SdoRelate(x.GEOMETRY, inputGeometry, "mask=ANYINTERACT") == "TRUE")
  4. .ToListAsync();
That way works nicely with EF Core 6 and 7 and older versions of dotConnect, but it fails with Devart.Data.Oracle.EFCore version 10.3.10.8 and EF Core 8. Has something changed in version 10.3.10.8 when it comes to handling geometries that causes that issue? Could you possibly fix it?

Here is an exception with the stacktrace:
  1. System.InvalidOperationException: Unexpected SqlParameterExpression implementation.
  2.     at Devart.Common.Entity.l.fe(String A_0, Type A_1, RelationalTypeMapping A_2)
  3.    at System.Data.Common.CommandTrees.a.a(SqlExpression A_0)
  4.    at System.Data.Common.CommandTrees.a.VisitSqlParameter(SqlParameterExpression sourceParameterExpression)
  5.    at Microsoft.EntityFrameworkCore.Query.SqlExpressionVisitor.VisitExtension(Expression extensionExpression)
  6.    at Devart.Common.Entity.y.VisitExtension(Expression extensionExpression)
  7.    at System.Data.Common.CommandTrees.a.a(s A_0)
  8.    at Devart.Common.Entity.y.b(s A_0)
  9.    at Devart.Common.Entity.w.Accept(ExpressionVisitor visitor)
  10.    at Devart.Common.Entity.y.h(SqlExpression A_0)
  11.    at Devart.Common.Entity.y.VisitSqlBinary(SqlBinaryExpression sqlBinaryExpression)
  12.    at System.Data.Common.CommandTrees.a.VisitSqlBinary(SqlBinaryExpression sqlBinaryExpression)
  13.    at Microsoft.EntityFrameworkCore.Query.SqlExpressionVisitor.VisitExtension(Expression extensionExpression)
  14.    at Devart.Common.Entity.y.VisitExtension(Expression extensionExpression)
  15.    at Devart.Common.Entity.y.h(SqlExpression A_0)
  16.    at Devart.Common.Entity.y.gb(SqlExpression A_0)
  17.    at Devart.Common.Entity.y.VisitSelect(SelectExpression selectExpression)
  18.    at System.Data.Common.CommandTrees.a.VisitSelect(SelectExpression selectExpression)
  19.    at System.Data.Common.CommandTrees.b.VisitSelect(SelectExpression source)
  20.    at Microsoft.EntityFrameworkCore.Query.SqlExpressionVisitor.VisitExtension(Expression extensionExpression)
  21.    at Devart.Common.Entity.y.VisitExtension(Expression extensionExpression)
  22.    at Microsoft.EntityFrameworkCore.Query.SqlExpressionVisitor.VisitExtension(Expression extensionExpression)
  23.    at Devart.Common.Entity.y.VisitExtension(Expression extensionExpression)
  24.    at Devart.Common.Entity.d0.Process(Expression query)
  25.    at Devart.Data.Oracle.Entity.i.Process(Expression query)
  26.    at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
  27.    at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
  28.    at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
  29.    at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass12_0`1.<ExecuteAsync>b__0()
  30.    at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
  31.    at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
  32.    at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
  33.    at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken)
  34.    at System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()
  35.    at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)