none
DateTimeOffset causing problems

    Question

  • Hi,

    I am trying to use the DateTimeOffset with my DataService but without success.  The entity model is able to successfully map to the type but when I query my WCF Data Service it just returns some html saying that there was a problem at the server.  This is true even when just querying for the metadata.  In the OData developer guide it says that Edm.DateTimeOffset is a primitive type. 

    Any chance that the WCF Data Services doesn't support the full OData protocol?  (I have set the service to use V2 of the OData protocol).

    Cheers,

    Clint


    clintsinger
    samedi 22 mai 2010 16:49

Réponses

Toutes les réponses

  • Hi,

    WCF Data Services currently doesn't support the DataTimeOffset primitive type. We are aware of this limitation, but if you want to express your interest in this feature please vote for it here: https://connect.microsoft.com/dataplatform/content/content.aspx?ContentID=15540&wa=wsignin1.0

    If DataTime would be enough for you, please expose your column as DateTime instead and WCF Data Services should work just fine.

    Thanks,


    Vitek Karas [MSFT]
    lundi 24 mai 2010 08:36
    Modérateur
  • Hi Vitek,

    Thanks for the information.  Just out of curiosity, what is the relationship to the OData protocol and the WCF Data Services?  I was under the impression that the OData protocol was defined by the WCF Data Services team, which is why I was surprised when I found a entity primitive in the OData spec that wasn't supported.   I thought that the OData was proposed as a standard after it was designed for use for the WCF Data Services.

    Cheers,

    Clint


    clintsinger
    mercredi 26 mai 2010 20:08
  • Hi Clint,

    You're right OData protocol was defined by us (the WCF Data Services team). But it being a protocol means that it should be implementation agnostic. As a result WCF Data Services is just one implementation which is not yet fully supporting the protocol. When we defined the protocol we knew about a few things we were not able to do in the product yet, but we knew that we want them in the protocol. So we added these. There are really just a very few of these though, the DateTimeOffset being one.

    Thanks,


    Vitek Karas [MSFT]
    jeudi 27 mai 2010 08:04
    Modérateur
  • Hi Vitek

    I'm trying to find out if there is any recommended workaround for supporting DateTimeOffset with WCF Data Services, other than changing the datatype to using DateTime instead. Unfortunately I am unable to change the datatype in the SQL database, so I have to be able to support DateTimeOffset in some way or another.

    Also, is there any timeframe that we can expect support for DateTimeOffset in WCF Data Services? Can we expect to see it in the near future?

    Your help is much appreciated.

    Thanks, Richard

    dimanche 22 août 2010 11:14
  • Hi Richard, Vitek

    Did you find a workaround for supporting DateTimeOffset with WCF Data Services?

    When you use a DateTime instead of a DateTimeOffset in SQL Database, timezones indicated in lexical representations are converted to UTC during conversion of literals to values. Is there a way to represent the Edm.DateTime with timezone as reccommended by ISO 8601? I found the following sample in http://msdn.microsoft.com/en-us/library/ff478141.aspx:  

    DateTime <d:foo m:type="Edm.DateTime">2010-02-26T17:08:53.0900752-08:00</d:foo> A date and time with value ranging from 12:00:00 midnight, January 1, 1753 A.D. through 11:59:59 P.M, December 9999 A.D. 

    How can I configure my WCF Data Service in order to have this representation? 

    Thanks in advance for your help.

    Regards, Marcello

    mercredi 1 septembre 2010 08:45
  • It has been more than a year since this was asked for.  If it is in the protocol, how long till you support it?

    It is silly really that SQL Server and EF Support it (the primary way for WCF Data Services to be setup) but that WCF Data Services does not support it...

    Now I have to go do some crazy hack to my data to try and separate datetime and the offset into two different values.  This will make my team look less favorably on using OData...

    lundi 25 juillet 2011 15:46
  • ...if you want to express your interest in this feature please vote for it here: https://connect.microsoft.com/dataplatform/content/content.aspx?ContentID=15540&wa=wsignin1.0

    That link is broken now.
    mardi 10 avril 2012 10:48
  • Hi,

    The new release : http://blogs.msdn.com/b/astoriateam/archive/2012/04/09/wcf-data-services-5-0-rtm-release.aspx

    Should support DateTimeOffset now.

    Thanks,


    Vitek Karas [MSFT]

    mardi 10 avril 2012 12:04
    Modérateur
  • Hi Vitek,

    After installing WCF Data Services 5.0 RTM, I still encountered the issue reported by clintsinger.

    Any other suggestion?

    Thanks,

    lisa

    jeudi 26 juillet 2012 05:20
  • Note that the 5.0 release renamed the assemblies (from System.Data.Services to Microsoft.Data.Services). So just installing the new assemblies onto your machine doesn't actually change anything. In order to use the new release you need to point your project to use the new assemblies.

    I would suggest you use NuGet to manage the dependencies for the 5.0 for you. That way it's also very easy to get updates and the redistribution of the assemblies with your app is also very simple. See this post for details: http://blogs.msdn.com/b/astoriateam/archive/2012/05/17/nuget-and-bin-deploy.aspx

    Thanks,


    Vitek Karas [MSFT]

    jeudi 26 juillet 2012 07:19
    Modérateur
  • Hi Vitek,

    After making the project reference the latest assemblies, it works.

    Thanks for your help!

    Lisa

    vendredi 27 juillet 2012 09:54