public SqlExpression?Translate(
        SqlExpression?instance,
        MemberInfo member,
        Type returnType,
        IDiagnosticsLogger <DbLoggerCategory.Query> logger)
    {
        if (typeof(Point).IsAssignableFrom(member.DeclaringType))
        {
            Check.DebugAssert(instance !.TypeMapping != null, "Instance must have typeMapping assigned.");
            var storeType   = instance.TypeMapping.StoreType;
            var isGeography = string.Equals(storeType, "geography", StringComparison.OrdinalIgnoreCase);

            if (MemberToPropertyName.TryGetValue(member, out var propertyName) ||
                (isGeography
                    ? GeographyMemberToPropertyName.TryGetValue(member, out propertyName)
                    : GeometryMemberToPropertyName.TryGetValue(member, out propertyName)) &&
                propertyName != null)
            {
                return(_sqlExpressionFactory.NiladicFunction(
                           instance,
                           propertyName,
                           nullable: true,
                           instancePropagatesNullability: true,
                           returnType));
            }
        }

        return(null);
    }
        /// <summary>
        ///     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.
        /// </summary>
        public virtual SqlExpression Translate(
            SqlExpression instance,
            MemberInfo member,
            Type returnType,
            IDiagnosticsLogger <DbLoggerCategory.Query> logger)
        {
            Check.NotNull(member, nameof(member));
            Check.NotNull(returnType, nameof(returnType));
            Check.NotNull(logger, nameof(logger));

            if (typeof(Geometry).IsAssignableFrom(member.DeclaringType))
            {
                Check.DebugAssert(instance.TypeMapping != null, "Instance must have typeMapping assigned.");
                var storeType   = instance.TypeMapping.StoreType;
                var isGeography = string.Equals(storeType, "geography", StringComparison.OrdinalIgnoreCase);

                if (_memberToFunctionName.TryGetValue(member, out var functionName) ||
                    (!isGeography && _geometryMemberToFunctionName.TryGetValue(member, out functionName)))
                {
                    var resultTypeMapping = typeof(Geometry).IsAssignableFrom(returnType)
                        ? _typeMappingSource.FindMapping(returnType, storeType)
                        : _typeMappingSource.FindMapping(returnType);

                    return(_sqlExpressionFactory.Function(
                               instance,
                               functionName,
                               Array.Empty <SqlExpression>(),
                               nullable: true,
                               instancePropagatesNullability: true,
                               argumentsPropagateNullability: Array.Empty <bool>(),
                               returnType,
                               resultTypeMapping));
                }

                if (Equals(member, _ogcGeometryType))
                {
                    var whenClauses = new List <CaseWhenClause>
                    {
                        new CaseWhenClause(
                            _sqlExpressionFactory.Constant("Point"), _sqlExpressionFactory.Constant(OgcGeometryType.Point)),
                        new CaseWhenClause(
                            _sqlExpressionFactory.Constant("LineString"), _sqlExpressionFactory.Constant(OgcGeometryType.LineString)),
                        new CaseWhenClause(
                            _sqlExpressionFactory.Constant("Polygon"), _sqlExpressionFactory.Constant(OgcGeometryType.Polygon)),
                        new CaseWhenClause(
                            _sqlExpressionFactory.Constant("MultiPoint"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiPoint)),
                        new CaseWhenClause(
                            _sqlExpressionFactory.Constant("MultiLineString"),
                            _sqlExpressionFactory.Constant(OgcGeometryType.MultiLineString)),
                        new CaseWhenClause(
                            _sqlExpressionFactory.Constant("MultiPolygon"),
                            _sqlExpressionFactory.Constant(OgcGeometryType.MultiPolygon)),
                        new CaseWhenClause(
                            _sqlExpressionFactory.Constant("GeometryCollection"),
                            _sqlExpressionFactory.Constant(OgcGeometryType.GeometryCollection)),
                        new CaseWhenClause(
                            _sqlExpressionFactory.Constant("CircularString"),
                            _sqlExpressionFactory.Constant(OgcGeometryType.CircularString)),
                        new CaseWhenClause(
                            _sqlExpressionFactory.Constant("CompoundCurve"),
                            _sqlExpressionFactory.Constant(OgcGeometryType.CompoundCurve)),
                        new CaseWhenClause(
                            _sqlExpressionFactory.Constant("CurvePolygon"),
                            _sqlExpressionFactory.Constant(OgcGeometryType.CurvePolygon))
                    };

                    if (isGeography)
                    {
                        whenClauses.Add(
                            new CaseWhenClause(
                                _sqlExpressionFactory.Constant("FullGlobe"), _sqlExpressionFactory.Constant((OgcGeometryType)126)));
                    }

                    return(_sqlExpressionFactory.Case(
                               _sqlExpressionFactory.Function(
                                   instance,
                                   "STGeometryType",
                                   Array.Empty <SqlExpression>(),
                                   nullable: true,
                                   instancePropagatesNullability: true,
                                   argumentsPropagateNullability: Array.Empty <bool>(),
                                   typeof(string)),
                               whenClauses,
                               null));
                }

                if (Equals(member, _srid))
                {
                    return(_sqlExpressionFactory.NiladicFunction(
                               instance,
                               "STSrid",
                               nullable: true,
                               instancePropagatesNullability: true,
                               returnType));
                }
            }

            return(null);
        }