Repository navigation
LINQ methods like Min, Max and Sum remain case sensitive when working with DateTime #967
Copy link
Copy link
Open
Description
We observed the strange behavior that the LINQ methods like Min, Max and Sum remain case sensitive when working with DateTime properties. When working with integers for example, thay are indeed case insensitive. We have the option IsCaseSensitive set to false.
Code to reproduce:
var models = new Model[]
{
new Model { Date = new DateTime(2025, 12, 10, 12, 0, 0) },
new Model { Date = new DateTime(2025, 8, 10, 12, 0, 0) }
};
var parameter = Expression.Parameter(typeof(Model[]), "models");
var parser = new ExpressionParser(
[parameter],
"models.MIN(x => x.Date)", // or min, MAX, max
[],
new ParsingConfig
{
IsCaseSensitive = false
});
var expression = parser.Parse(typeof(DateTime));
var labmda = Expression.Lambda<Func<Model[], DateTime>>(expression, parameter);
var method = labmda.Compile();
var result = method(models);
Console.Write(result);
public class Model
{
public DateTime Date { get; set; }
}Exception:
Unhandled exception. System.InvalidOperationException: No generic method 'MIN' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
at System.Linq.Expressions.Expression.FindMethod(Type type, String methodName, Type[] typeArgs, Expression[] args, BindingFlags flags)
at System.Linq.Expressions.Expression.Call(Type type, String methodName, Type[] typeArguments, Expression[] arguments)
at System.Linq.Dynamic.Core.Parser.ExpressionParser.TryParseEnumerable(Expression instance, Type enumerableType, String methodName, Type type, Expression[]& args, Expression& expression)
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseMemberAccess(Type type, Expression expression, String id)
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParsePrimary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseUnary()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseArithmetic()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAdditive()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseShiftOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseComparisonOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLogicalAndOrOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseIn()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAndOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseOrOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLambdaOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseNullCoalescingOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseConditionalOperator()
at System.Linq.Dynamic.Core.Parser.ExpressionParser.Parse(Type resultType, Boolean createParameterCtor)
Libary version: 1.7.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]LINQ's methods like Min, Max and Sum remain case sensitive when working with DateTime[/-][+]LINQ methods like Min, Max and Sum remain case sensitive when working with DateTime[/+]banator99 commentedon Dec 3, 2025
This line may be the cause?
System.Linq.Dynamic.Core/src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs
Line 2207 in c0e417c
It does not perform a case insensitive check. Not sure why this isn't an issue with integers.
Anyway, none of
Contains(methodName)calls are case insensitive.If I'm stepping through the code with the debugger and making it enter the branch of the line above (while keeping the name fully uppercase), the code works like expected.