Я пытаюсь отфильтровать поля DateTime?
моих классов с помощью общей функции. Но у меня ошибка "The LINQ expression could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync()."
И я не знаю, что не так.
Это моя функция расширения:
public static IQueryable<TEntity>? FilterDateField<TEntity>(this IQueryable<TEntity> entities, Expression<Func<TEntity, DateTime?>> dbField, DateTime dateField)
{
var t1 = entities.Where(e=>dbField.Compile().Invoke(e).HasValue && dbField.Compile().Invoke(e)== dateField);
return t1;
}