Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle.EntityFrameworkCore beta3 Specified cast is not valid

Sergey PechenikApr 10 2019 — edited Apr 12 2019

Hello!

I'm trying to read entity from table. But catching

System.InvalidCastException:  'Specified cast is not valid.'

   at Oracle.ManagedDataAccess.Client.OracleDataReader.GetString(Int32 i)

   at lambda_method(Closure , DbDataReader )

   at Microsoft.EntityFrameworkCore.Storage.Internal.TypedRelationalValueBufferFactory.Create(DbDataReader dataReader)

   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferAll()

   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)

   at Microsoft.EntityFrameworkCore.Storage.ExecutionStrategy.ExecuteImplementation[TState,TResult](Func`3 operation, Func`3 verifySucceeded, TState state)

   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()

   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider._TrackEntities[TOut,TIn](IEnumerable`1 results, QueryContext queryContext, IList`1 entityTrackingInfos, IList`1 entityAccessors)+MoveNext()

   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()

   at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)

   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

   at Opn.Lib.Dotnet.EntityFramework.Core.TestConsole.MyHostedService..ctor(TestDbContext context) in C:\Sources\UFS.Dotnet.Lib\opn.lib.dotnet.entityframework.core\Opn.Lib.Dotnet.EntityFramework.Core.TestConsole\MyHostedService.cs:line 13

Table script:

  CREATE TABLE "ITEMSSTORE"     (     "ID" NUMBER(38,0) NOT NULL ENABLE,       "BIGNUM38" NUMBER(38,0),       "BIGINTCOL" NUMBER(19,0),       "INTCOL" NUMBER(10,0),       "GUIDCOL" RAW(16),       "DATECOL" DATE,       "DATETIMEOFFSETCOL" TIMESTAMP (6) WITH TIME ZONE,       "DECIMALCOL" NUMBER(28,0),       "STRINGCOL" NVARCHAR2(2000),       "DATETIMECOL" TIMESTAMP (6),       "TIMECOL" INTERVAL DAY (2) TO SECOND (6),        CONSTRAINT "ITEMSSTORE_PK" PRIMARY KEY ("ID")    );  INSERT INTO itemsstore (     bignum38,     bigintcol,     intcol,     guidcol,     datecol,     datetimeoffsetcol,     decimalcol,     stringcol,     datetimecol,     timecol ) VALUES (     12345678912345678912345678912345678912,     9223372036854775807,     2147483647,     'fd55e62a0646449f9375a0d86449f77c',     '01-01-2001',     '01-01-01 12:12 +3:00',     9228162514264337593543950335,     N'У попа была собака он её любил, она съела кусок мяса он её убил, закопал её в могилу на могиле написал, у попа была собака он её любил...',     '01-01-01 12:12',     INTERVAL '11:20' HOUR TO MINUTE );

Entity:

    [Table("ITEMSSTORE")]     internal class TestItems     {         [Column("ID")]         [Key]         public long? Id { get; set; }          [Column("BIGNUM38")]         [MaxLength(38)]         public string GiantCol { get; set; }          [Column("BIGINTCOL")]         public long? BigIntCol { get; set; }          [Column("INTCOL")]         public int? IntCol { get; set; }          [Column("GUIDCOL")]         public Guid? GuidCol { get; set; } // В базе это Raw[16]          [Column("DATECOL")]         public DateTime? DateCol { get; set; }          [Column("DATETIMEOFFSETCOL")]         public DateTimeOffset? DateTimeOffsetCol { get; set; }          [Column("DECIMALCOL")]         public decimal? DecCol { get; set; }          [Column("STRINGCOL")]         [MaxLength(2000)]
        public string StrCol { get; set; }          [Column("DATETIMECOL")]         public DateTime? DateTimeCol { get; set; }          [Column("TIMECOL")]         public TimeSpan? TimeCol { get; set; }     }
This post has been answered by Alex Keh-Oracle on Apr 10 2019
Jump to Answer

Comments

Processing

Post Details

Added on Apr 10 2019
3 comments
3,483 views