System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
josue.agnese
Posts: 9
Joined: Tue 21 Aug 2018 13:56

System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by josue.agnese » Tue 12 Mar 2019 12:58

Hi!

We are using Devart.Data.PostgreSql.EFCore 7.12.1328 and PostgreSQL version:
"PostgreSQL 11.2 (Debian 11.2-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit".

I reproduced my scenario to share with you (https://drive.google.com/open?id=1plGUX ... Q0Q1FE6kxL).
I have a complex query, with a complex model data (including DateTimeOffset fields), where I use the let operator with some aggregation operations.
When I try to execute a query I get this exception as a result:

System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'.
at . (Object , Int32 )
at .(Object , ? , Int32 )
at . ( )
at .(Expression )
at .(BinaryExpression )
at .VisitBinary(BinaryExpression )
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at .(String , Expression , Expression )
at .(BinaryExpression )
at .VisitBinary(BinaryExpression )
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at Microsoft.EntityFrameworkCore.Query.Sql.DefaultQuerySqlGenerator.VisitConditional(ConditionalExpression conditionalExpression)
at System.Linq.Expressions.ConditionalExpression.Accept(ExpressionVisitor visitor)
...

Thank you for reading.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by Shalex » Fri 15 Mar 2019 11:19

Thank you for your report. We have reproduced the issue and are investigating it. We will notify you about the result.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by Shalex » Fri 29 Mar 2019 11:37

The translation of DateTimeOffset literal into SQL statement is supported: viewtopic.php?f=3&t=38516.

josue.agnese
Posts: 9
Joined: Tue 21 Aug 2018 13:56

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by josue.agnese » Mon 08 Apr 2019 16:10

Hi!

Running in Debug mode it's works, but when I publish the code:

Microsoft.EntityFrameworkCore.Query[10100]
An exception occurred while iterating over the results of a query for context type 'Devart.PostgreSql.SchedulerContext'.
System.ArgumentNullException: Value cannot be null.
Parameter name: queryCompilationContext
at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName)
at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression..ctor(SelectExpressionDependencies dependencies, RelationalQueryCompilationContext queryCompilationContext)
at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.Clone(String alias)
at ? . ? ? (SelectExpression )
at ? . ? ? (SelectExpression )
at System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node)
at ? .VisitUnary(UnaryExpression )
at System.Linq.Expressions.UnaryExpression.Accept(ExpressionVisitor visitor)
at ? .VisitBinary(BinaryExpression )
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at ? . ? ? (Ordering )
at ? . ? ? (SelectExpression )
at ? . ? ? (SelectExpression )
at System.Linq.Expressions.ExpressionVisitor.VisitAndConvert[T](T node, String callerName)
at .CreateDefault(SelectExpression )
at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.<NotifyReaderCreated>b__14_0(FactoryAndReader s)
at Microsoft.EntityFrameworkCore.Internal.NonCapturingLazyInitializer.EnsureInitialized[TParam,TValue](TValue& target, TParam param, Func`2 valueFactory)
at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.NotifyReaderCreated(DbDataReader dataReader)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.BufferlessMoveNext(DbContext _, Boolean buffer, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.MoveNext(CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.AsyncSelectEnumerable`2.AsyncSelectEnumerator.MoveNext(CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext(CancellationToken cancellationToken)
System.ArgumentNullException: Value cannot be null.
Parameter name: queryCompilationContext
at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName)
at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression..ctor(SelectExpressionDependencies dependencies, RelationalQueryCompilationContext queryCompilationContext)
at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.Clone(String alias)
at ? . ? ? (SelectExpression )
at ? . ? ? (SelectExpression )
at System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node)
at ? .VisitUnary(UnaryExpression )
at System.Linq.Expressions.UnaryExpression.Accept(ExpressionVisitor visitor)
at ? .VisitBinary(BinaryExpression )
at System.Linq.Expressions.BinaryExpression.Accept(ExpressionVisitor visitor)
at ? . ? ? (Ordering )
at ? . ? ? (SelectExpression )
at ? . ? ? (SelectExpression )
at System.Linq.Expressions.ExpressionVisitor.VisitAndConvert[T](T node, String callerName)
at .CreateDefault(SelectExpression )
at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.<NotifyReaderCreated>b__14_0(FactoryAndReader s)
at Microsoft.EntityFrameworkCore.Internal.NonCapturingLazyInitializer.EnsureInitialized[TParam,TValue](TValue& target, TParam param, Func`2 valueFactory)
at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.NotifyReaderCreated(DbDataReader dataReader)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.BufferlessMoveNext(DbContext _, Boolean buffer, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.MoveNext(CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.AsyncSelectEnumerable`2.AsyncSelectEnumerator.MoveNext(CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext(CancellationToken cancellationToken)
Value cannot be null.
Parameter name: queryCompilationContext

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by Shalex » Thu 11 Apr 2019 19:14

Please send us a small test project to reproduce the issue in our environment.

josue.agnese
Posts: 9
Joined: Tue 21 Aug 2018 13:56

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by josue.agnese » Fri 12 Apr 2019 11:02

[url]https://drive.google.com/open?id=1 ... oDONFOHF0F[/url]

This exception throw when the application published in docker environment.
In debug mode it's works!

Run in application path:
- docker build -t devart:bug .
- docker run devart:bug

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by Shalex » Tue 23 Apr 2019 17:11

Thank you for your report. We have reproduced the issue and are investigating it.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by Shalex » Wed 22 May 2019 11:02

We have sent the internal build to you by email.

Please test this build with your application. Additionally, set the following option in your code:

Code: Select all

  var config = Devart.Data.PostgreSql.Entity.Configuration.PgSqlEntityProviderConfig.Instance;
  config.QueryOptions.Optimizations = Data.PostgreSql.Entity.Configuration.QueryOptimizations.None;

josue.agnese
Posts: 9
Joined: Tue 21 Aug 2018 13:56

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by josue.agnese » Thu 23 May 2019 17:34

Hi! I received your internal build!

This internal build support .NET Core assemblies ?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by Shalex » Fri 24 May 2019 10:49

The NuGet packages for v7.13.1392 are uploaded to https://www.devart.com/pub/nuget_postgr ... 3_1392.zip.

josue.agnese
Posts: 9
Joined: Tue 21 Aug 2018 13:56

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by josue.agnese » Fri 24 May 2019 17:23

Hi!

With your internal build it worked.
Will this be available in the next release version?

Code: Select all

var config = Devart.Data.PostgreSql.Entity.Configuration.PgSqlEntityProviderConfig.Instance;

config.QueryOptions.Optimizations = Data.PostgreSql.Entity.Configuration.QueryOptimizations.None;

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: System.NotSupportedException: Unsupported literal primitive type kind 'DateTimeOffset'

Post by Shalex » Mon 27 May 2019 09:00

josue.agnese wrote: Fri 24 May 2019 17:23Will this be available in the next release version?
Yes, it will. The property is public but not browsable.

Post Reply