Entity Framework Oracle Timestamp — oracle-tech

    Forum Stats

  • 3,716,133 Users
  • 2,242,960 Discussions
  • 7,845,840 Comments

Discussions

Howdy, Stranger!

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

Entity Framework Oracle Timestamp

Selim YILDIZ
Selim YILDIZ Member Posts: 1
edited September 2019 in ODP.NET

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,};this.ObjectSet.Add(newItem);this.SaveChanges();

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.

SELECT "Extent1"."INSTANCE_ID" AS "INSTANCE_ID", FROM "DGARSMART"."T_SC_SERVICE" "Extent1"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:

 <package id="Oracle.ManagedDataAccess" version="12.2.1100" targetFramework="net45" /> <package id="Oracle.ManagedDataAccess.EntityFramework" version="12.2.20190115" targetFramework="net45" /> <package id="EntityFramework" version="6.0.0" targetFramework="net45" />
4082208

Answers

Sign In or Register to comment.