Search code examples
c#wcfdatacontract

How to convert the data type of a property in a DataContract on client side?


I have a WCF service which returns a List<MyData> object. MyData is a DataContract class with bunch of properties in it, one of which is UnixTime of type Int64. I want this in C# DateTime format. I know how to convert unix time to regular DateTime values. What I want to know is, is there a way that I can change my DataContract on the client side (or some other idea) where in I can convert the unix time to regular time format so that I can directly access the value from my List<MyData> object?

Edit:
I am not actually adding the service reference to my solution. I am calling the wcf service throught the HttpWebRequest object and deserializing the output response using the JavaScriptSerializer. I created my own classes for the data contract as the response object.


Solution

  • Thanks Tim S for the helpful tip.

    I created a new property called MSDateTime in my MyData class without the [DataMember] attribute and returned the converted value of my unixtime. That solved the problem.