Using NodaTime in SQLite.Net

For a project I wanted to try out NodaTime, because of its nice handling with timezones.
In this project I have also to save the values into a SQLite database and for that I normally use for that.
Normally does not know how to handle the NodaTime types, but there are 2 places to add your own support for types.

1.) ExtraTypeMapping
You can specific for your types which SQLite type it should be. That could be INTEGER, REAL, TEXT or BLOB.
It’s a simply Dictionary<System.Type, String> you provide as constructor parameter, where you set the Type to BLOB.

2.) IBlobSerializer
When you save your values as Blob, you can use the BlobSerializerDelegate of and provide the appropriate delegates to serialize and deserialize your types.

When you combine both, you can simply save your own types as blob in your database.

The code for saving LocalDate, OffsetDateTime and Duration you can find here:

It is in F#, but it is understandable by C#-only developers. 😉