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 trying to add/subtract types 'DateTime' and 'TimeSpan' #737

Closed
MihailTanasoglo opened this issue Aug 21, 2023 · 3 comments
Closed
Assignees
Labels

Comments

@MihailTanasoglo
Copy link

MihailTanasoglo commented Aug 21, 2023

1. Description

Starting from version 1.3, when trying ParseLambda to add / subtract the DateTime and TimeSpan types, we get an exception.

2. Exception

Exception message:

System.Exception : Lambda eval error: Operator '-' incompatible with operand types 'DateTime' and 'TimeSpan', expression: (myDateTime-myTimeSpan) ----> System.Linq.Dynamic.Core.Exceptions.ParseException : Operator '-' incompatible with operand types 'DateTime' and 'TimeSpan'
Stack trace:
This exception was originally thrown at this call stack:
    System.Linq.Dynamic.Core.Parser.ExpressionParser.CheckAndPromoteOperands(System.Type, System.Linq.Dynamic.Core.Tokenizer.TokenId, string, ref System.Linq.Expressions.Expression, ref System.Linq.Expressions.Expression, int)
    System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAdditive()
    System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseShiftOperator()
    System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseComparisonOperator()
    System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLogicalAndOrOperator()
    System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseIn()
    System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAndOperator()
    System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseOrOperator()
    System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLambdaOperator()
    System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseNullCoalescingOperator()

3. Any further technical details

I call the method like this:

Expression result = System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(typeof(object), expression, parameters);

Where
expression is "(myDateTime-myTimeSpan)"
parameters is dictionary with corresponding names and values

@StefH StefH self-assigned this Aug 21, 2023
@MihailTanasoglo
Copy link
Author

image
image

I apologize in advance if my assumption is incompetent.
Perhaps this error is caused by changes in the screenshot.
Add support for DateOnly and TimeOnly (#671)

@StefH
Copy link
Collaborator

StefH commented Aug 23, 2023

Thank you for the explanation. I'll fix this.

@StefH StefH added the bug label Aug 23, 2023
@StefH
Copy link
Collaborator

StefH commented Aug 23, 2023

#739

@StefH StefH closed this as completed Aug 23, 2023
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