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

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>
/// 设置主键 /// 设置主键
/// </summary> /// </summary>
public class SetupKey : IEntityColumnServices public class SetupKeyColumnServices : IEntityColumnServices
{ {
/// <inheritdoc/> /// <inheritdoc/>
public void SetupColumn(PropertyInfo p, EntityColumnInfo c) { public void SetupColumn(PropertyInfo p, EntityColumnInfo c) {

View File

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

View File

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

View File

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