Link Search Menu Expand Document

MdsSqLiteDbTypeNameToClientTypeResolver


This IResolver<string, Type> implementation converts a SQLite column data type name into its equivalent .NET CLR type, specifically for the Microsoft.Data.Sqlite driver (“Mds”). It is the default DbTypeResolver used by SqLiteDbHelper when initialized via SqliteBootstrap.

Reflecting how Microsoft.Data.Sqlite reads back loosely-typed SQLite columns, boolean, char, date, datetime, none, string, text, time and varchar all resolve to string, while bigint, decimal, int, integer and numeric all resolve to long.

Compare this with SdsSqLiteDbTypeNameToClientTypeResolver — for the System.Data.SQLite.Core driver, date/datetime/time resolve to DateTime, boolean resolves to long, and decimal/numeric resolve to decimal. Using the wrong one of the two against a given driver will misrepresent these column types.

Usability

var resolver = new MdsSqLiteDbTypeNameToClientTypeResolver();
var clrType = resolver.Resolve("text"); // typeof(string)