diff options
author | crupest <crupest@outlook.com> | 2022-12-05 09:02:50 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-12-20 20:32:52 +0800 |
commit | 2d63ac857ed1082f6f7d365674aa734c582a99dd (patch) | |
tree | dfdf7e18710b858a1ce7d0f9c34c5f071d649578 /docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/CrudService.cs | |
parent | 131e40d79dff8622464de3285588945beab4e39b (diff) | |
download | crupest-2d63ac857ed1082f6f7d365674aa734c582a99dd.tar.gz crupest-2d63ac857ed1082f6f7d365674aa734c582a99dd.tar.bz2 crupest-2d63ac857ed1082f6f7d365674aa734c582a99dd.zip |
Develop secret api. v6
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; } |