Question

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.

Était-ce utile?

La solution 2

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.

Autres conseils

You can add a DateTime property to your MyData class:

public DateTime UnixDateTime
{
    get
    {
        return MyConversionMethod(this.UnixTime);
    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top