Constantinos Eraleous - 15 - Jan 26, 2015

Hi there,

I have all my DateTime properties handled as
JsConfig<DateTime>.SerializeFn = date =>date.ToShortDateString();

but I need for some specific DTOs , not all, to include the time as well.
Is that possible?


Mike Mertsock:

I am handling this by declaring the date-only properties as strings in the DTO and doing the parsing/serializing by hand. When implementing that I couldn’t think of a more elegant solution. So if there is a better way I’d like to hear about it as well.

Yeah using a string is the easiest way. There’s also a JsConfig<T>.OnSerializingFn which is called on serializing specific DTO’s, here you could remove the time portion out of specific DTO’s DateTimes.