locked
WCF Data services remove miliseconds from DateTime when expand RRS feed

  • Question

  • I get some strange behavior, when using WCF Data Services 5.6. In my case, I have table, with 1 column set with Concurrency=Fixed, and this column hold date time field from database, updated each time when row is edited. In case I just retrieve entity - this column has correct value with milliseconds. But if I do mapping - milliseconds are removed.

    Here is a issue at glance :

    ====================================================================

    void Main()
    {
        var b = from p in TABLE1 where p.ID == 100 select p;
        b.Dump();
    }

    Request in this case is : Data.svc/TABLE1(100M) And data returned from service is :

    <d:COL1 m:type="Edm.DateTime">2015-02-16T12:13:52.972</d:COL1>

    ====================================================================

    As you can see , here time is returned with milliseconds - .972 In other case :

    void Main()
    {
    
        var tmp = from p in TABLE1 where p.ID == 100 select 
        new TABLE1() 
        {
            ID=p.ID,
            COL1=p.COL1
        };
        var a1 = tmp.ToList();
        a1.Dump();
    }

    Request in this case is : Data.svc/TABLE1(100M)?$select=ID,COL1

      <d:COL1 m:type="Edm.DateTime">2015-02-16T12:13:52</d:COL1>

    ====================================================================

    Time is returned without milliseconds.

    Does anybody have same problem? May be its a bug in the WCF Data services or in the model?

    Tuesday, February 17, 2015 12:46 PM

Answers

  • Ok, seems like I found an answer to this, or at least way to avoid the problem.
    First I traced generated SQL from framework, and I see that in first case, im getting SQL

         SELECT ID, COL1 FROM TABLE1

    and in second case, I got

         SELECT ID, CAST( COL1 AS DATETIME) FROM TABLE1

    which cause the problem.

    Then I tried to update EF to version 6, WCF Data services to version 5.6.3,
    Oracle ODP to latest one, tried to use Oracle managed driver... no any success.

    Then I played little bit with table definition, and I saw that my col1 with type TIMESTAMP in database and DateTime in the model was defined as NOT NULL.
    If I remove this from database definition, I got right value with milliseconds.

    So , may be this is a bug in Oracle driver, but probably this is a bug in the WCF Data Services. At least I found a way to use concurrency in my case with this solution.

    Monday, February 23, 2015 12:00 PM

All replies

  • Nobody has similar problem?
    Friday, February 20, 2015 9:55 AM
  • Ok, seems like I found an answer to this, or at least way to avoid the problem.
    First I traced generated SQL from framework, and I see that in first case, im getting SQL

         SELECT ID, COL1 FROM TABLE1

    and in second case, I got

         SELECT ID, CAST( COL1 AS DATETIME) FROM TABLE1

    which cause the problem.

    Then I tried to update EF to version 6, WCF Data services to version 5.6.3,
    Oracle ODP to latest one, tried to use Oracle managed driver... no any success.

    Then I played little bit with table definition, and I saw that my col1 with type TIMESTAMP in database and DateTime in the model was defined as NOT NULL.
    If I remove this from database definition, I got right value with milliseconds.

    So , may be this is a bug in Oracle driver, but probably this is a bug in the WCF Data Services. At least I found a way to use concurrency in my case with this solution.

    Monday, February 23, 2015 12:00 PM