I'm just starting to play around with NPoco, but as of yet I haven't located what I need in the docs.
For instance, let's say I have a field Created
, which is an Instant
in my domain, but a DateTimeOffset
set to UTC in my database. Is there a way to have NPoco convert these types?
I expanded on the interface that Schotime demonstrated and built it out for several NodaTime types. Too big to paste here, so here is a GIST.
Note that it doesn't include ZonedDateTime
, which would have to be serialized to two different fields, so I'm not sure how NPoco would deal with that. I also didn't include Period
, since there's no great corresponding type other than a varchar
.
Warning: This code is completely untested. I'm just applying what I know about Noda Time conversions to the overrides that the other answer illustrated. Please test it thoroughly before using in your code.