Pomelo.EntityFrameworkCore.MySql
Pomelo.EntityFrameworkCore.MySql copied to clipboard
EndsWith translation
Steps to reproduce
// This works
db.Set.Where(x => x.String.EndsWith("*"))
// This does not work
db.Set.Where(x => x.String.EndsWith('*'))
The issue
EndsWith can be translated if a string is the provided argument, but will not be if it is a character instead. However in my opinion it should not be an issue to implement this.
Further technical details
Pomelo.EntityFrameworkCore.MySql version: 6.0.1
Typically not all method overloads are supported in Translations. The general rule is that if it's supported by SQL Server then other providers will follow (for cross compatibility). In this particular use case, since the workaround is straightforward then the benefit-cost ratio to support it is low.
@IvMisticos If you feel this is an important method call, feel free to add a translation to MySqlStringMethodTranslator.cs, add a test or two and send us a PR.
since the workaround is straightforward then the benefit-cost ratio to support it is low.
I agree with @mguinness .
It's different from the situation between string.IndexOf(string value)
and string.IndexOf(string value, int startIndex)
. string.EndsWith(char value)
is originally added for optimization on common usage. On the aspect of ef core, it's a little meaningless for sql translation.