JasperFx / marten

.NET Transactional Document DB and Event Store on PostgreSQL
https://martendb.io
MIT License
2.74k stars 428 forks source link

BadLinqExpressionException when calling string.Trim #3276

Open ovyshnevskyy opened 2 weeks ago

ovyshnevskyy commented 2 weeks ago

After upgrade to Marten "7.19.1" we get next error: Marten.Exceptions.BadLinqExpressionException Marten does not (yet) support member string.Trim

In previous version of Marten next code works fine:

return (await GetAsync( tenantId, values => values.Where(x => x.Name.Trim().Equals(name.Trim(), StringComparison.OrdinalIgnoreCase)), cancellationToken)) .FirstOrDefault();

Are you going to fix this in next versions?

jeremydmiller commented 2 weeks ago

Marten has never supported string.Trim() in LINQ expressions. Maybe it didn't throw an exception on before, but that's not something that's ever been explicitly supported -- an you literally have to explicitly write code to handle every damn thing you could possibly do in LINQ because it's not magic.

This wasn't something that was on my radar at all. Happy to take a PR for this if you want to dive into it. Start with StringMember