-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hello!
I'm just trying to get a feel for this library. I need some guidance on how to get the marked code below to not throw exception when deserializing null data to a null LocalDate. what might be the easiest workaround?? thank you for helping!
static void NodaTimeModelCsvTest()
{
//one-time setup to register NodaTime serializers with ServiceStack
DateTimeZoneProviders.Tzdb
.CreateDefaultSerializersForNodaTime()
.ConfigureSerializersForNodaTime();
var nodatimeModels = new List<NodaTimeModel>();
var data = new List<NodaTimeModel>()
{
new NodaTimeModel { CreatedAt = LocalDate.FromDateTime(DateTime.Now), CreatedBy = "one"},
new NodaTimeModel { CreatedAt = LocalDate.FromDateTime(DateTime.Now), CreatedBy = "two"},
new NodaTimeModel { CreatedAt = null, CreatedBy = "evan"}
};
var str = CsvSerializer.SerializeToCsv<NodaTimeModel>(data);
nodatimeModels = str.FromCsv<List<NodaTimeModel>>(); //****this throws cannot be null exception; would like it to be ok to deserialize into a null LocalDate
}
}
public class NodaTimeModel
{
public int Id { get; set; }
public LocalDate? CreatedAt { get; set; }
public string CreatedBy { get; set; }
}
Metadata
Metadata
Assignees
Labels
No labels