diff options
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs')
-rw-r--r-- | docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs index d5edd13..bc4ed50 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs @@ -60,30 +60,15 @@ public class CrudService<TEntity> } } - public string GetDatabaseTypeName(Type type) + public string GetSqlType(Type type) { - if (type == typeof(int)) - { - return "INTEGER"; - } - else if (type == typeof(double)) - { - return "REAL"; - } - else if (type == typeof(bool)) - { - return "BOOLEAN"; - } - else - { - throw new DatabaseInternalException($"Type {type} is not supported."); - } + return ColumnTypeInfoRegistry.Singleton.GetSqlType(type); } public string GetCreateTableColumnSql() { var properties = typeof(TEntity).GetProperties(); - var sql = string.Join(", ", properties.Select(p => $"{p.Name} {GetDatabaseTypeName(p.PropertyType)}")); + var sql = string.Join(", ", properties.Select(p => $"{p.Name} {GetSqlType(p.PropertyType)}")); return sql; } |