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

[Help] Trying to use System.Linq.Dynamic.Core with MongoDB IQueryable #344

Closed
dthk-cogmatix opened this issue Jan 18, 2020 · 1 comment
Closed
Assignees
Labels

Comments

@dthk-cogmatix
Copy link

I'm running into an issue when trying to use System.Linq.Dynamic.Core with MongoDB's client.

Example)

Works
IQueryable query1 = collection.AsQueryable<BsonDocument>().AsQueryable().Where("Birthdate <= @0", DateTime.Now);

Doesn't Work:
IQueryable query1 = collection.AsQueryable<BsonDocument>().AsQueryable().Where("Birthdate <= DateTime.Now");

(Throwing the exception): System.Linq.Dynamic.Core.Exceptions.ParseException: 'Operator '<=' incompatible with operand types 'BsonValue' and 'DateTime''

BsonValue is the actual type of BirthDate and is wrapping DateTime. I have tried to get the actual DateTime value, such as:

IQueryable query1 = collection.AsQueryable<BsonDocument>().AsQueryable().Where("Birthdate.AsDateTime <= DateTime.Now");

But receive a different exception: System.InvalidOperationException: 'The operands for operator 'LessThanOrEqual' do not match the parameters of method 'op_LessThanOrEqual'.'

Any thoughts, suggestions here?

I don't have issues with simple expressions such as:
IQueryable query1 = collection.AsQueryable<BsonDocument>().AsQueryable().Where("FirstName == \"John\"");

@StefH StefH added the question label Feb 4, 2020
@StefH StefH self-assigned this Apr 26, 2024
@StefH
Copy link
Collaborator

StefH commented Apr 26, 2024

Maybe solved by #805.
Closing for now.

@StefH StefH closed this as completed Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants