using NoFurion; using SqlSugar; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Reflection; namespace Dolphin.ExamPictureCut.Domains; public class MySqlConfigureExternalServices { public static ConfigureExternalServices MySqlExtService = new ConfigureExternalServices { EntityService = delegate (PropertyInfo prop, EntityColumnInfo col) { if (prop.GetCustomAttribute() != null) { col.IsIgnore = true; } if (!col.IsPrimarykey) { if (prop.GetCustomAttribute() != null) { return; } if (new NullabilityInfoContext().Create(prop).WriteState == NullabilityState.Nullable || prop.PropertyType == typeof(string)) { col.IsNullable = true; } } var sugarColumn = prop.GetCustomAttribute(); if (sugarColumn != null && sugarColumn.ColumnName.IsNotNullOrEmpty()) { return; } if (prop.DeclaringType.GetCustomAttribute() == null) { col.DbColumnName = UtilMethods.ToUnderLine(col.DbColumnName); } }, EntityNameService = delegate (Type t, EntityInfo entity) { if (t.GetCustomAttribute() != null) { return; } TableAttribute customAttribute = t.GetCustomAttribute(); if (customAttribute != null) { entity.DbTableName = UtilMethods.ToUnderLine(customAttribute.Name); } } }; }