1 Reply Latest reply on Sep 11, 2019 11:08 PM by Alex Keh - Product Manager-Oracle

    Entity Framework Oracle Timestamp

    Selim YILDIZ

      We have table named T_SC_SERVICE has INSTANCE_ID column which is type Timestamp(6).


      I'm using Entity Framework 6 and DB first approaches.


      I'am trying to Add and Select item for this table with using LINQ.

      Insert with LINQ as shown below:


      Service newItem = new Service()
          InstanceId = DateTime.Now,


      That LINQ generates SQL as below. As you can see INSTANCE_ID parameter send as DateTime as expected.


      insert into "DGARSMART"."T_SC_SERVICE"("INSTANCE_ID")
      values (:p0)
      -- :p0: '29.08.2019 07:33:38' (Type = DateTime)
      -- Executing at 29.08.2019 07:33:38 +03:00
      -- Completed in 66 ms with result: 1


      Here is my Problem:


      SELECT with LINQ as shown below:


      internal Service GetServiceByInstanceId(DateTime instanceId)


      return this.ObjectSet.FirstOrDefault(i => i.InstanceId == instanceId);



      That LINQ generates SQL as below. As you can see Instance_ID send as Date not DateTime. So it always return Null. This is the same entity object and same model. I could not figure out why this LINQ is sending DateTime as Type of Date instead of DateTime.


      "Extent1"."INSTANCE_ID" AS "INSTANCE_ID", 
      WHERE (("Extent1"."INSTANCE_ID" = :p__linq__0) AND (:p__linq__0 IS NOT NULL)) AND (ROWNUM <= (1) 
      -- p__linq__0: '29.08.2019 07:33:38' (Type = Date)
      -- Executing at 29.08.2019 07:34:47 +03:00
      -- Completed in 5 ms with result: OracleDataReader



      I'am using these packages: