修复一个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 { };
//设置Nullable
this.ConfigureExternalServices.EntityService += (p, c) => {
var pt = p.PropertyType;
if (pt.GetCustomAttribute<RequiredAttribute>() != null) {
if (p.GetCustomAttribute<RequiredAttribute>() != null) {
c.IsNullable = false;
return;
}
var pt = p.PropertyType;
if (pt.IsGenericType && pt.GetGenericTypeDefinition() == typeof(Nullable<>)) {
c.IsNullable = true;
return;