in EFCore/src/Query/Expressions/Internal/MySQLStringComparisonMethodTranslator.cs [413:497]
public SqlExpression? MakeContainsExpression(
SqlExpression target,
SqlExpression search,
SqlExpression? stringComparison = null)
{
if (stringComparison == null)
{
return MakeContainsExpressionImpl(
target,
e => e,
search,
e => e);
}
if (TryGetExpressionValue<StringComparison>(stringComparison, out var cmp))
{
return CreateExpressionForCaseSensitivity(
cmp,
() =>
MakeContainsExpressionImpl(
target,
e => e,
search,
e => Utf8Bin(e)
),
() =>
MakeContainsExpressionImpl(
target,
e => LCase(e),
search,
e => Utf8Bin(LCase(e))
)
);
}
else
{
#if !NET8_0_OR_GREATER
return new CaseExpression(
new[]
{
new CaseWhenClause(
_sqlExpressionFactory.In(stringComparison, _caseSensitiveComparisons, false),
// Case sensitive, accent sensitive
MakeContainsExpressionImpl(
target,
e => e,
search,
e => Utf8Bin(e)
)
)
},
// Case insensitive, accent sensitive
MakeContainsExpressionImpl(
target,
e => LCase(e),
search,
e => Utf8Bin(LCase(e))
)
);
#else
return new CaseExpression(
new[]
{
new CaseWhenClause(
_sqlExpressionFactory.In(stringComparison,(IReadOnlyList<SqlExpression>) _caseSensitiveComparisons),
// Case sensitive, accent sensitive
MakeContainsExpressionImpl(
target,
e => e,
search,
e => Utf8Bin(e)
)
)
},
// Case insensitive, accent sensitive
MakeContainsExpressionImpl(
target,
e => LCase(e),
search,
e => Utf8Bin(LCase(e))
)
);
#endif
}
}