I'm struggling with what I thought should be simple, I've a database table in an azure DB which has a column called "CreatedOn" the datatype of this column in database is "DateTimeOffset".
My timezone is IST(+5:30), i'm trying to populate values in this table, using Entity Framework through a RESTful WCF service using JsonSerializer.
The problem is that no offset value goes inside database when I make the service call through a windows phone app.
The property is declared as follows.
/// <summary>
/// Gets or sets the created on.
/// </summary>
[DataMember]
public DateTimeOffset? CreatedOn
{
get
{
return DateTime.Now;
}
set
{
this.OnPropertyChanged("CreatedOn");
}
}
The class knows "DateTimeOffset" through known types.
[KnownType(typeof(DateTimeOffset?))]
[DataContract]
public class MyTableItem : TableBase
At the time of populating the object, I've tried all of the following
tableItem.CreatedOn = DateTime.Now;
tableItem.CreatedOn = DateTime.UtcNow;
tableItem.CreatedOn = DateTime.SpecifyKind(DateTime.Now,DateTimeKind.Utc)
nothing works, what i get is shown in the image below. The offset is always 00:00, the ones which are showing correct values, are added without using azure WCF.
the image url is http://sdrv.ms/18Kz3HT