优化数据库列服务,支持所有数据库

This commit is contained in:
falcon 2022-10-14 12:21:21 +08:00
parent cdc0f5f1a0
commit c9fcd28181
4 changed files with 8 additions and 9 deletions

View File

@ -7,7 +7,7 @@ namespace Falcon.SugarApi.DatabaseDefinitions.EntityServices
/// <summary>
/// 设置主键
/// </summary>
public class SetupKey : IEntityColumnServices
public class SetupKeyColumnServices : IEntityColumnServices
{
/// <inheritdoc/>
public void SetupColumn(PropertyInfo p, EntityColumnInfo c) {

View File

@ -9,7 +9,7 @@ namespace Falcon.SugarApi.DatabaseDefinitions.EntityServices
/// <summary>
/// 设置长度规则
/// </summary>
public class SetupLength : IEntityColumnServices
public class SetupLengthColumnServices : IEntityColumnServices
{
/// <inheritdoc/>
public void SetupColumn(PropertyInfo p, EntityColumnInfo c) {
@ -20,10 +20,9 @@ namespace Falcon.SugarApi.DatabaseDefinitions.EntityServices
if (p.TryGetAttribute<MaxLengthAttribute>(out var la)) {
len.Add(la.Length);
}
if (p.TryGetAttribute<SugarColumn>(out var sc) && sc.Length != 0) {
len.Add(sc.Length);
if (len.Any()) {
c.Length = len.Max();
}
c.Length = len.Max();
}
}
}

View File

@ -8,7 +8,7 @@ namespace Falcon.SugarApi.DatabaseDefinitions.EntityServices
/// <summary>
/// 设置Nullable
/// </summary>
public class SetupNullable : IEntityColumnServices
public class SetupNullableColumnServices : IEntityColumnServices
{
/// <inheritdoc/>
public void SetupColumn(PropertyInfo p, EntityColumnInfo c) {

View File

@ -32,9 +32,9 @@ namespace Falcon.SugarApi.DatabaseDefinitions
static SugarConnectionConfig() {
TableServices.Add(new TableNameTableService());
ColumnServices.Add(new SetupKey());
ColumnServices.Add(new SetupLength());
ColumnServices.Add(new SetupNullable());
ColumnServices.Add(new SetupKeyColumnServices());
ColumnServices.Add(new SetupLengthColumnServices());
ColumnServices.Add(new SetupNullableColumnServices());
}
/// <summary>