From ea7116f0ce142a0a18e763577375e160d8799f78 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 22 Oct 2025 20:02:35 +0800 Subject: [PATCH 1/2] Apply type mapping to StartsWith argument Fix https://bugs.mysql.com/bug.php?id=118460 --- EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs b/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs index c3697e56c..33938783f 100644 --- a/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs +++ b/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs @@ -179,8 +179,9 @@ public MySQLStringMethodTranslator(ISqlExpressionFactory sqlExpressionFactory) if (_startsWithMethodInfo.Equals(method)) { + var stringTypeMapping = ExpressionExtensions.InferTypeMapping(instance!, arguments[0]); return new MySQLStringComparisonMethodTranslator(_sqlExpressionFactory) - .MakeStartsWithExpression(instance!, arguments[0], _sqlExpressionFactory.Constant(StringComparison.CurrentCulture)); + .MakeStartsWithExpression(instance!, _sqlExpressionFactory.ApplyTypeMapping(arguments[0], stringTypeMapping), _sqlExpressionFactory.Constant(StringComparison.CurrentCulture)); } if (_endsWithMethodInfo.Equals(method)) From 6dc43ce418952122b115dedaf289b639c1b88f3c Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 22 Oct 2025 20:07:32 +0800 Subject: [PATCH 2/2] Apply type mapping to arguments in EndsWith translation --- EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs b/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs index 33938783f..8bf3c643e 100644 --- a/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs +++ b/EFCore/src/Query/Internal/MySQLStringMethodTranslator.cs @@ -186,8 +186,9 @@ public MySQLStringMethodTranslator(ISqlExpressionFactory sqlExpressionFactory) if (_endsWithMethodInfo.Equals(method)) { + var stringTypeMapping = ExpressionExtensions.InferTypeMapping(instance!, arguments[0]); return new MySQLStringComparisonMethodTranslator(_sqlExpressionFactory) - .MakeEndsWithExpression(instance!, arguments[0], _sqlExpressionFactory.Constant(StringComparison.CurrentCulture)); + .MakeEndsWithExpression(instance!, _sqlExpressionFactory.ApplyTypeMapping(arguments[0], stringTypeMapping), _sqlExpressionFactory.Constant(StringComparison.CurrentCulture)); } if (_padLeftWithOneArg.Equals(method))