public static DbType GetDbType(this Type type) {
if (type.IsNullable()) {
type = type.GetGenericArguments()[0];
}
if (TypeMap.ContainsKey(type)) {
return TypeMap[type];
}
// just use underlying type of enum
if (!type.IsEnum) {
throw new ArgumentOutOfRangeException("type", "Unable to determine the DBType for type: " + type.FullName);
}
var enumType = Enum.GetUnderlyingType(type);
if (TypeMap.ContainsKey(enumType)) {
return TypeMap[enumType];
}
throw new ArgumentOutOfRangeException("type", "Unable to determine the DBType for type: " + type.FullName);
}