Dapper.NET Installing a TypeHandler


Example

The above type handler can be installed into SqlMapper using the AddTypeHandler method.

SqlMapper.AddTypeHandler<IHtmlString>(new IHtmlStringTypeHandler());

Type inference allows you to omit the generic type parameter:

SqlMapper.AddTypeHandler(new IHtmlStringTypeHandler());

There's also a two-argument overload which takes an explicit Type argument:

SqlMapper.AddTypeHandler(typeof(IHtmlString), new IHtmlStringTypeHandler());