Skip to content

System.Linq.Dynamic.Core.Exceptions.ParseException : No applicable method 'DateTime' exists in type #662

Closed
@ascott18

Description

1. Description

I am unable to use the documented constructor syntax when the type being constructed has the same name as a property on the queried type. See fiddle. For example - .Where("it.DateTime > DateTime(2022, 1, 1, 0, 0, 0)")

This worked in versions at or prior to 1.0.22. It was broken in 1.0.23, presumably by #357. It continues to be broken in 1.2.24.

2. Exception

  Message: 
System.Linq.Dynamic.Core.Exceptions.ParseException : No applicable method 'DateTime' exists in type 'Foo'

  Stack Trace: 
ExpressionParser.ParseMemberAccess(Type type, Expression expression)
ExpressionParser.ParseIdentifier()
ExpressionParser.ParsePrimaryStart()
ExpressionParser.ParsePrimary()
ExpressionParser.ParseUnary()
ExpressionParser.ParseMultiplicative()
ExpressionParser.ParseAdditive()
ExpressionParser.ParseShiftOperator()
ExpressionParser.ParseComparisonOperator()
ExpressionParser.ParseLogicalAndOrOperator()
<20 more frames...>
ExpressionParser.ParseConditionalOperator()
ExpressionParser.Parse(Type resultType, Boolean createParameterCtor)
DynamicExpressionParser.ParseLambda(Type delegateType, ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values)
DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, ParameterExpression[] parameters, Type resultType, String expression, Object[] values)
DynamicExpressionParser.ParseLambda(ParsingConfig parsingConfig, Boolean createParameterCtor, Type itType, Type resultType, String expression, Object[] values)
DynamicQueryableExtensions.Where(IQueryable source, ParsingConfig config, String predicate, Object[] args)
DynamicQueryableExtensions.Where[TSource](IQueryable`1 source, ParsingConfig config, String predicate, Object[] args)
DynamicQueryableExtensions.Where[TSource](IQueryable`1 source, String predicate, Object[] args)

3. Fiddle or Project

https://dotnetfiddle.net/6j1G9U

4. Any further technical details

Metadata

Assignees

Labels

Type

No type

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions