优化数据库列服务,支持所有数据库
This commit is contained in:
parent
cdc0f5f1a0
commit
c9fcd28181
|
@ -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) {
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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) {
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user