From 128f5f60256cf2b9faeb8d45dd3379123d83d71c Mon Sep 17 00:00:00 2001 From: falcon <9504402@qq.com> Date: Thu, 2 Mar 2023 10:37:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=86=99sqlsugar=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=88=97=E9=95=BF=E5=BA=A6=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SetupLengthColumnServices.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Falcon.SugarApi/DatabaseDefinitions/EntityServices/SetupLengthColumnServices.cs b/Falcon.SugarApi/DatabaseDefinitions/EntityServices/SetupLengthColumnServices.cs index 7be2c9e..7661087 100644 --- a/Falcon.SugarApi/DatabaseDefinitions/EntityServices/SetupLengthColumnServices.cs +++ b/Falcon.SugarApi/DatabaseDefinitions/EntityServices/SetupLengthColumnServices.cs @@ -1,4 +1,5 @@ using SqlSugar; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; @@ -9,22 +10,19 @@ namespace Falcon.SugarApi.DatabaseDefinitions.EntityServices /// /// 设置长度规则 /// - public class SetupLengthColumnServices : IEntityColumnServices + public class SetupLengthColumnServices:IEntityColumnServices { /// - public void SetupColumn(PropertyInfo p, EntityColumnInfo c) { - var len = new List(); - if (p.TryGetAttribute(out var sl)) { + public void SetupColumn(PropertyInfo p,EntityColumnInfo c) { + var len = new List { }; + if(p.TryGetAttribute(out var sl)) { len.Add(sl.MaximumLength); } - if (p.TryGetAttribute(out var la)) { + if(p.TryGetAttribute(out var la)) { len.Add(la.Length); } - if (p.TryGetAttribute(out var sc)) { - len.Add(sc.Length); - } - if (len.Any()) { - c.Length = len.Max(); + if(len.Any()) { + c.Length=len.Reduce(c.Length,(m,i) => Math.Max(m,i)); } } }