diff --git a/src/EFCore.SqlServer.NTS/Extensions/SqlServerNetTopologySuiteServiceCollectionExtensions.cs b/src/EFCore.SqlServer.NTS/Extensions/SqlServerNetTopologySuiteServiceCollectionExtensions.cs index 36ef4579b1c..802a8e982d1 100644 --- a/src/EFCore.SqlServer.NTS/Extensions/SqlServerNetTopologySuiteServiceCollectionExtensions.cs +++ b/src/EFCore.SqlServer.NTS/Extensions/SqlServerNetTopologySuiteServiceCollectionExtensions.cs @@ -31,7 +31,8 @@ public static IServiceCollection AddEntityFrameworkSqlServerNetTopologySuite( new EntityFrameworkRelationalServicesBuilder(serviceCollection) .TryAdd() .TryAdd() - .TryAdd(); + .TryAdd() + .TryAdd(); return serviceCollection; } diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteEvaluatableExpressionFilterPlugin.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteEvaluatableExpressionFilterPlugin.cs new file mode 100644 index 00000000000..d3622c073de --- /dev/null +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteEvaluatableExpressionFilterPlugin.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal; + +/// +/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to +/// the same compatibility standards as public APIs. It may be changed or removed without notice in +/// any release. You should only use it directly in your code with extreme caution and knowing that +/// doing so can result in application failures when updating to a new Entity Framework Core release. +/// +public class SqlServerNetTopologySuiteEvaluatableExpressionFilterPlugin : IEvaluatableExpressionFilterPlugin +{ + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + public virtual bool IsEvaluatableExpression(Expression expression) + { + if (expression is MethodCallExpression methodCallExpression + && methodCallExpression.Method.DeclaringType == typeof(SqlServerNetTopologySuiteDbFunctionsExtensions)) + { + return false; + } + + return true; + } +} diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteMethodCallTranslatorPlugin.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteMethodCallTranslatorPlugin.cs index b5af0008674..4ea128a6706 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteMethodCallTranslatorPlugin.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteMethodCallTranslatorPlugin.cs @@ -26,8 +26,8 @@ public SqlServerNetTopologySuiteMethodCallTranslatorPlugin( new SqlServerGeometryMethodTranslator(typeMappingSource, sqlExpressionFactory), new SqlServerGeometryCollectionMethodTranslator(typeMappingSource, sqlExpressionFactory), new SqlServerLineStringMethodTranslator(typeMappingSource, sqlExpressionFactory), - new SqlServerPolygonMethodTranslator(typeMappingSource, sqlExpressionFactory), - new SqlServerNetTopologySuiteDbFunctionsMethodCallTranslator(typeMappingSource, sqlExpressionFactory) + new SqlServerNetTopologySuiteDbFunctionsMethodCallTranslator(typeMappingSource, sqlExpressionFactory), + new SqlServerPolygonMethodTranslator(typeMappingSource, sqlExpressionFactory) }; }