Pomelo.EntityFrameworkCore.MySql icon indicating copy to clipboard operation
Pomelo.EntityFrameworkCore.MySql copied to clipboard

EndsWith translation

Open IvMisticos opened this issue 3 years ago • 3 comments

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

IvMisticos avatar Feb 06 '22 15:02 IvMisticos

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.

mguinness avatar Feb 06 '22 19:02 mguinness

@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.

lauxjpn avatar Feb 08 '22 11:02 lauxjpn

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.

LeaFrock avatar May 16 '22 13:05 LeaFrock