user2013301
user2013301

Reputation:

Azure Table Insert issue

I am facing an issue while inserting an entity. I am not sure what is wrong in there. As I insert, I get an StorageClientException stating "value out of range".

My Table Service Entity looks like

public class Itinerary : TableServiceEntity
{
     public string Name { get; set; }
     public DateTime DOB { get; set; }
     public int Sex { get; set; }
     public string ToPNR { get; set; }
     public string ReturnPNR { get; set; }
     public string ContactNumber { get; set; } 
     public DateTime TravelDate { get; set; }
     public DateTime ReturnDate { get; set; }
}

The entity gets inserted when the complete itinerary details are provided, but for itinerary having only one side details, the insert method gets failed with the given exception.

Any help would be appreciated.

Upvotes: 2

Views: 639

Answers (1)

Tinu
Tinu

Reputation: 695

The problem I guess lies with your DateTime fields. If you haven't initialized them before storing your data in the Table Storage, then the values that will be assigned to these fields will be that of .NET DateTime.Min value. Unfortunately this value is out of bounds of Azure Table Storage. Hence it is always advisable to provide some value to your DateTime field in the Azure Table Storage. In case, you want to assign a default value to the same, use the CloudTableClient.MinSupportedDateTime property. This will initialize the field with the min value supported by Azure Storage - http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.cloudtableclient.minsupporteddatetime.aspx

Hope this helps

Upvotes: 6

Related Questions