DateTime in expression mapping
mward-smartway2 opened this issue · 7 comments
public IEnumerable Get(Expression<Func<TDto, bool>> lambda, string includes = "", Func<IQueryable, IOrderedQueryable> orderBy = null, int? skip = null, int? take = null)
{
var orderByFunc = Mapper.Map<Func<IQueryable, IOrderedQueryable>>(orderBy);
var lambdaFunc = Mapper.MapExpression<Expression<Func<TRepository, bool>>>(lambda);
var list = Repository.Get(lambdaFunc, includes, orderByFunc, skip, take);
return Mapper.Map<IEnumerable>(list);
}
when lambda is x => x.SomeDateTime >= SomeOtherDateTime
MapExpression modifies the types correctly but leaves lambdaFunc as x => x.SomeDateTime >= const DateTime(string)
which cannot be used in a LInq to SQL expression by the Repository.
This problem does not exist in version 9.0 with ExpressionMapping 3.1.2 only in 10.0 with ExpresionMapping 4.
Please post a sample we can run and see the unexpected results.
Show today's generated expression and the expression from the earlier release (which works against your database).
Isolated Sample attached
I have added code which shows the Exception
The sample does not show an exception related to this library.
This test in the OData Extensions library maps date constants in a filter expression (using this library).
I did't say that the exception was in this Library, merely that the exression was modified in such a way as make it unusable in EFCore 3.1 with Microsoft.Data.SqlClient.
It also fails with Microsoft.EntityFrameworkCore.SqlServer 5.0