Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when Using ToLowerInvariant() in Query Expression #2467

Open
KrzysztofPajak opened this issue Apr 4, 2024 · 0 comments
Open

Exception when Using ToLowerInvariant() in Query Expression #2467

KrzysztofPajak opened this issue Apr 4, 2024 · 0 comments
Labels

Comments

@KrzysztofPajak
Copy link

KrzysztofPajak commented Apr 4, 2024

Version
5.0.19
Exception: Method ToLowerInvariant() in String are not supported when convert to BsonExpression

Describe the bug
When using the ToLowerInvariant() method within the query expression, LiteDB throws an exception. This behavior occurs consistently whenever ToLowerInvariant() is utilized in the query expression.

Code to Reproduce
Create a query expression using ToLowerInvariant() method.
Execute the query with LiteDB.
Expected Behavior:
The query should execute without throwing any exceptions, even when ToLowerInvariant() method is used.

Code Example:
collection.FindOne(x => x.Id == "1".ToLowerInvariant())

Actual Behavior:
LiteDB throws an exception when ToLowerInvariant() method is used in the query expression.

StackTrace:
at LiteDB.LinqExpressionVisitor.VisitMethodCall(MethodCallExpression node)
at LiteDB.LinqExpressionVisitor.VisitAsPredicate(Expression expr, Boolean ensurePredicate)
at LiteDB.LinqExpressionVisitor.VisitBinary(BinaryExpression node)
at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression1 node) at LiteDB.LinqExpressionVisitor.VisitLambda[T](Expression1 node)
at LiteDB.LinqExpressionVisitor.Resolve(Boolean predicate)
at LiteDB.BsonMapper.GetExpression[T,K](Expression1 predicate) at LiteDB.LiteCollection1.FindOne(Expression`1 predicate)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant