Difference between Dates / Entity Framework Core 3.1 — oracle-tech

    Forum Stats

  • 3,708,688 Users
  • 2,241,109 Discussions
  • 7,840,539 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Difference between Dates / Entity Framework Core 3.1

14957991495799 Posts: 8
edited July 2020 in ODP.NET

Hello,

I have an exception when I try to get the difference between two dates (in Days) with the new Oracle.EntityFrameworkCore 3.19.0-beta1 NuGet package :

var row = (

        from r in dbContext.Entitites

        select new { (DateTime.Now - r.DateTimeColumn).Days }

    ).FirstOrDefault();

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

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

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

   at System.Data.Common.DbDataReader.GetFieldValue[T](Int32 ordinal)

42639653818723

Best Answer

  • Alex Keh-OracleAlex Keh-Oracle Posts: 2,720 Employee
    edited July 2020 Accepted Answer

    Yes, this bug will be fixed in production. The fix just missed our beta 2 freeze date.

Answers

  • 37995773799577 Posts: 5
    edited May 2020

    Hi,

    didn't see your post before mine but you can look at it for a temporary solution: Using DateTime.Today breaks with Entity Framework Core 3.1

    Looks like if you pass a variable instead of DateTime.Now, it works.

    Alex Keh-Oracle
  • Alex Keh-OracleAlex Keh-Oracle Posts: 2,720 Employee
    edited May 2020

    I've filed Bug 31423881 to track this issue. The Oracle team will review the bug.

  • 14957991495799 Posts: 8
    edited June 2020

    Can you make the bugs public so we can track their status ?

    4263965
  • Alex Keh-OracleAlex Keh-Oracle Posts: 2,720 Employee
    edited June 2020

    user2082593

    Unfortunately, I cannot publish with beta bugs. Nonetheless, I'm happy to update the status.

    My team tried to reproduce the issue with the same query, but do not see the error. We created a table with a DateTime column, inserted a value, then ran the query. Are there other necessary conditions that need to be present for the error to occur? For example, does it occur with certain results only or a different time-based column type?

  • 14957991495799 Posts: 8
    edited June 2020

    Here is a sample project (with an EF migration to create the table) that reproduces the problem : https://github.com/kakone/OracleBug31423881
    I use an Oracle Server version 12.1.0.1.0 on Windows.

    Alex Keh-Oracle
  • Alex Keh-OracleAlex Keh-Oracle Posts: 2,720 Employee
    edited June 2020

    Thanks for the test case! I can reproduce the problem. I will upload your test case to the bug.

    3818723
  • 14957991495799 Posts: 8
    edited July 2020

    The bug is not fixed with the beta 2 ;(
    Is there any hope that it will be fixed in the final release ?

  • Alex Keh-OracleAlex Keh-Oracle Posts: 2,720 Employee
    edited July 2020 Accepted Answer

    Yes, this bug will be fixed in production. The fix just missed our beta 2 freeze date.

Sign In or Register to comment.