I\'m getting this message,\"The string \'7/22/2006 12:00:00 AM\' is not a valid AllXsd value.\", when deserializing an XML, the element contains a date, this is the property
AllocationDate is a mandatory field but can be supplied as blank which is handled by representing it by AllocationDateString:
private DateTime? _allocationDate;
[XmlIgnore]
public DateTime? AllocationDate
{
get { return _allocationDate; }
set { _allocationDate = value; }
}
[XmlAttribute("AllocationDateTime")]
public string AllocationDateTimeString
{
get
{
return _allocationDate.HasValue ? XmlConvert.ToString(_allocationDate.Value, XmlDateTimeSerializationMode.Unspecified)
: string.Empty;
}
set
{
_allocationDate = !string.IsNullOrEmpty(value) ? XmlConvert.ToDateTime(value, XmlDateTimeSerializationMode.Unspecified) : (DateTime?)null;
}
}