添加codeFirst功能

This commit is contained in:
陈淳
2022-10-18 18:01:16 +08:00
parent dab4a092d9
commit ab8cdd88b9
25 changed files with 161 additions and 121 deletions

View File

@@ -4,6 +4,7 @@ using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
@@ -50,9 +51,16 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
{
EntityService = (c, p) =>
{
// int? decimal?这种 isnullable=true
if (c.PropertyType.IsGenericType &&
c.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
//// int? decimal?这种 isnullable=true
//if (c.PropertyType.IsGenericType &&
//c.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
//{
// p.IsNullable = true;
//}
//高版C#写法 支持string?和string
if (new NullabilityInfoContext()
.Create(c).WriteState is NullabilityState.Nullable)
{
p.IsNullable = true;
}