CockroachDbDbTypeNameToCockroachDbTypeResolver

A class used to resolve a CockroachDB database type name into its equivalent CockroachDbType.

This IResolver<string, CockroachDbType?> implementation converts a CockroachDB database type name into its equivalent RepoDb.Connector.CockroachDb.CockroachDbType. It resolves in three steps:

  1. Tries to parse the name directly as a CockroachDbType enum member.
  2. Returns null for the reflection-reported USER-DEFINED type (e.g. a native enum type) — CockroachDbType has no Unknown member to fall back to.
  3. Otherwise, falls back to CockroachDbDbTypeNameToClientTypeResolver to get the .NET CLR type, then ClientTypeToCockroachDbTypeResolver to resolve that type into its CockroachDbType — returning null instead of throwing if that final step can’t resolve it either.

Usability

var resolver = new CockroachDbDbTypeNameToCockroachDbTypeResolver();
var cockroachDbType = resolver.Resolve("uuid"); // CockroachDbType.Uuid