重写sqlsugar判断列长度的方法
This commit is contained in:
parent
eb66061fa2
commit
128f5f6025
|
@ -1,4 +1,5 @@
|
|||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
|
@ -13,18 +14,15 @@ namespace Falcon.SugarApi.DatabaseDefinitions.EntityServices
|
|||
{
|
||||
/// <inheritdoc/>
|
||||
public void SetupColumn(PropertyInfo p,EntityColumnInfo c) {
|
||||
var len = new List<int>();
|
||||
var len = new List<int> { };
|
||||
if(p.TryGetAttribute<StringLengthAttribute>(out var sl)) {
|
||||
len.Add(sl.MaximumLength);
|
||||
}
|
||||
if(p.TryGetAttribute<MaxLengthAttribute>(out var la)) {
|
||||
len.Add(la.Length);
|
||||
}
|
||||
if (p.TryGetAttribute<SugarColumn>(out var sc)) {
|
||||
len.Add(sc.Length);
|
||||
}
|
||||
if(len.Any()) {
|
||||
c.Length = len.Max();
|
||||
c.Length=len.Reduce(c.Length,(m,i) => Math.Max(m,i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user