question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.NotSupportedException: SQLite cannot order by expressions of type 'DateTimeOffset'

See original GitHub issue

Describe the problem/bug I’m no longer able to view my invoices page.

I believe this started happening after I upgraded from v1.0.3.133 to v1.0.3.152. I also installed .NET 3, because NBExplorer insisted ont hat.

Your environment

  • Version of BTCPay Server: v1.0.3.152 (NBExplorer v2.1.7)
  • Deployment method: manual (checkout tag, ./build.sh, restart systemd service)
  • Other relevant environment details: Ubuntu 18.04

Logs (if applicable)

Jan 17 13:09:29 sjimmie dotnet[29347]: fail: Microsoft.AspNetCore.Server.Kestrel: Connection id "0HLSR8O8H82A0", Request id "0HLSR8O8H82A0:00000001": An unhandled exception was thrown by the application.
Jan 17 13:09:29 sjimmie dotnet[29347]: System.NotSupportedException: SQLite cannot order by expressions of type 'DateTimeOffset'. Convert the values to a supported type or use LINQ to Objects to order the results.
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Sqlite.Query.Internal.SqliteQueryableMethodTranslatingExpressionVisitor.TranslateOrderBy(ShapedQueryExpression source, LambdaExpression keySelector, Boolean ascending)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass12_0`1.<ExecuteAsync>b__0()
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.IncludableQueryable`2.GetAsyncEnumerator(CancellationToken cancellationToken)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToArrayAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at BTCPayServer.Services.Invoices.InvoiceRepository.GetInvoices(InvoiceQuery queryObject) in /home/btcpay/btcpayserver/BTCPayServer/Services/Invoices/InvoiceRepository.cs:line 609
Jan 17 13:09:29 sjimmie dotnet[29347]:    at BTCPayServer.Controllers.InvoiceController.ListInvoices(String searchTerm, Int32 skip, Int32 count, Int32 timezoneOffset) in /home/btcpay/btcpayserver/BTCPayServer/Controllers/InvoiceController.UI.cs:line 420
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
Jan 17 13:09:29 sjimmie dotnet[29347]: --- End of stack trace from previous location where exception was thrown ---
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
Jan 17 13:09:29 sjimmie dotnet[29347]: --- End of stack trace from previous location where exception was thrown ---
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
Jan 17 13:09:29 sjimmie dotnet[29347]:    at BTCPayServer.Hosting.BTCPayMiddleware.Invoke(HttpContext httpContext) in /home/btcpay/btcpayserver/BTCPayServer/Hosting/BTCpayMiddleware.cs:line 75
Jan 17 13:09:29 sjimmie dotnet[29347]:    at BTCPayServer.Hosting.HeadersOverrideMiddleware.Invoke(HttpContext httpContext) in /home/btcpay/btcpayserver/BTCPayServer/Hosting/HeadersOverrideMiddleware.cs:line 31
Jan 17 13:09:29 sjimmie dotnet[29347]:    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
NicolasDoriercommented, Mar 10, 2020

Made new release 163

1reaction
Sjorscommented, Jan 17, 2020

v1.0.3.153 works by the way

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling DateTimeOffset in SQLite with Entity Framework Core
System.NotSupportedException : SQLite cannot order by expressions of type 'DateTimeOffset'. Convert the values to a supported type or use ...
Read more >
A Warning For EF Core's DateTimeOffsetToBinaryConverter
System.NotSupportedException : SQLite cannot order by expressions of type 'DateTimeOffset'. Convert the values to a supported type or use ...
Read more >
DateTimeOffset expression could not be translated in EF. ...
Simple LINQ query could not be translated in EF.Sqlite 2.2: queryable.Where(e => e.CreationDate > DateTimeOffset.Now) It worked with EF.
Read more >
SQLite sort order on datetime column populated from C# ...
The datetime column is populated with data generated by the Metro application in C#; for example as DateTimeOffset. Now . WinRT doesn't support ......
Read more >
Handling DateTimeOffset in SQLite with Entity Framework ...
System.NotSupportedException : SQLite cannot order by expressions of type 'DateTimeOffset'. Convert the values to a supported type or use LINQ to Objects to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found