In order to create a custom type converter, the interface you need to implement is
As you can see, the interface is quite simple only requiring 3 methods.
CanConvert method allows the converter to tell MicroLite if it can handle conversion of the specified type. This will be called by MicroLite when it is trying to resolve the correct type converter to use to convert a value.
ConvertFromDbValue method will be called by MicroLite when building an object from a result set, the value will be the object returned by the underlying DbDataReader and the type will be the property type (or object type if include scalar or execute scalar has been called).
ConvertToDbValue method will be called by MicroLite when building an insert/update statement. The value will be the property value and the type will be the property type.
Once you have created an
ITypeConverter, simply register it when you configure MicroLite:
using MicroLite.TypeConverter; TypeConverter.Converters.Add(new MyCustomTypeConverter());