diff options
| author | crupest <crupest@outlook.com> | 2022-12-06 21:03:36 +0800 | 
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2022-12-20 20:32:52 +0800 | 
| commit | 1870bc78d4a2733246322c5540761da852afe713 (patch) | |
| tree | 7dd05378a17e6b687af4987fe50e425171f0e07b /docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs | |
| parent | c16159d9ef9e3b3f359966d17f3aa6eb420620f6 (diff) | |
| download | crupest-1870bc78d4a2733246322c5540761da852afe713.tar.gz crupest-1870bc78d4a2733246322c5540761da852afe713.tar.bz2 crupest-1870bc78d4a2733246322c5540761da852afe713.zip | |
Develop secret api. v16
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs')
| -rw-r--r-- | docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs | 38 | 
1 files changed, 10 insertions, 28 deletions
| diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs index 1754c8d..081071f 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Crud/ColumnInfo.cs @@ -20,11 +20,11 @@ public class ColumnInfo      }      // A column with no property. -    public ColumnInfo(Type entityType, string sqlColumnName, bool isPrimaryKey, bool isAutoIncrement, IColumnTypeInfo typeInfo, ColumnIndexType indexType = ColumnIndexType.None, ColumnTypeInfoRegistry? typeRegistry = null) +    public ColumnInfo(Type entityType, string sqlColumnName, bool isPrimaryKey, bool isAutoIncrement, ColumnTypeInfo typeInfo, ColumnIndexType indexType = ColumnIndexType.None, ColumnTypeRegistry? typeRegistry = null)      {          if (typeRegistry is null)          { -            typeRegistry = ColumnTypeInfoRegistry.Singleton; +            typeRegistry = ColumnTypeRegistry.Instance;          }          EntityType = entityType; @@ -40,11 +40,11 @@ public class ColumnInfo          IndexType = indexType;      } -    public ColumnInfo(Type entityType, string entityPropertyName, ColumnTypeInfoRegistry? typeRegistry = null) +    public ColumnInfo(Type entityType, string entityPropertyName, ColumnTypeRegistry? typeRegistry = null)      {          if (typeRegistry is null)          { -            typeRegistry = ColumnTypeInfoRegistry.Singleton; +            typeRegistry = ColumnTypeRegistry.Instance;          }          EntityType = entityType; @@ -73,25 +73,8 @@ public class ColumnInfo              DefaultEmptyForString = columnAttribute.DefaultEmptyForString;          } -        ColumnTypeInfo = typeRegistry.GetRequiredByDataType(PropertyRealType); +        ColumnTypeInfo = typeRegistry.GetRequired(PropertyRealType);          TypeRegistry = typeRegistry; - -        if (DefaultEmptyForString) -        { -            EntityPostGet += (entity, column, _, _) => -            { -                var pi = column.PropertyInfo; -                if (pi is not null && column.ColumnTypeInfo.GetUnderlineType() == typeof(string)) -                { -                    var value = pi.GetValue(entity); -                    if (value is null) -                    { -                        pi.SetValue(entity, string.Empty); -                    } -                } -                return Task.CompletedTask; -            }; -        }      }      public Type EntityType { get; } @@ -101,18 +84,17 @@ public class ColumnInfo      public Type PropertyType { get; }      public Type PropertyRealType { get; }      public string SqlColumnName { get; } -    public ColumnTypeInfoRegistry TypeRegistry { get; set; } -    public IColumnTypeInfo ColumnTypeInfo { get; } +    public ColumnTypeRegistry TypeRegistry { get; set; } +    public ColumnTypeInfo ColumnTypeInfo { get; }      public bool Nullable { get; }      public bool IsPrimaryKey { get; }      public bool IsAutoIncrement { get; }      public ColumnIndexType IndexType { get; } -    public bool DefaultEmptyForString { get; } -    public event EntityPreSave? EntityPreSave; -    public event EntityPostGet? EntityPostGet; +    // TODO: Implement this behavior. +    public bool DefaultEmptyForString { get; } -    public string SqlType => TypeRegistry.GetSqlTypeRecursive(ColumnTypeInfo); +    public string SqlType => ColumnTypeInfo.SqlType;      public string GenerateCreateTableColumnString()      { | 
