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!

Entity Framework Oracle Timestamp

Selim YILDIZSep 2 2019 — edited Sep 11 2019

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" />

Comments
Post Details
Added on Sep 2 2019
3 comments
1,152 views