修复一个Nullable设置错误

This commit is contained in:
falcon 2022-09-09 12:50:59 +08:00
parent 6a888ca9be
commit 5dddabe868

View File

@ -22,11 +22,11 @@ namespace Falcon.SugarApi.DatabaseDefinitions
this.ConfigureExternalServices ??= new ConfigureExternalServices { }; this.ConfigureExternalServices ??= new ConfigureExternalServices { };
//设置Nullable //设置Nullable
this.ConfigureExternalServices.EntityService += (p, c) => { this.ConfigureExternalServices.EntityService += (p, c) => {
var pt = p.PropertyType; if (p.GetCustomAttribute<RequiredAttribute>() != null) {
if (pt.GetCustomAttribute<RequiredAttribute>() != null) {
c.IsNullable = false; c.IsNullable = false;
return; return;
} }
var pt = p.PropertyType;
if (pt.IsGenericType && pt.GetGenericTypeDefinition() == typeof(Nullable<>)) { if (pt.IsGenericType && pt.GetGenericTypeDefinition() == typeof(Nullable<>)) {
c.IsNullable = true; c.IsNullable = true;
return; return;