Dynamically constructed class attributes can be of this class

This commit is contained in:
sunkaixuan
2023-11-30 04:33:29 +08:00
parent 169d52b824
commit 56e26baac3
2 changed files with 31 additions and 1 deletions

View File

@@ -24,7 +24,16 @@ namespace SqlSugar
foreach (PropertyMetadata property in properties)
{
EmitTool.CreateProperty(typeBuilder, property.Name, property.Type, property.CustomAttributes);
var type = property.Type;
if (type == typeof(DynamicOneselfType))
{
type = typeBuilder;
}
else if (type == typeof(DynamicOneselfTypeList))
{
type = typeof(List<>).MakeGenericType(typeBuilder);
}
EmitTool.CreateProperty(typeBuilder, property.Name, type, property.CustomAttributes);
}
Type dynamicType = typeBuilder.CreateTypeInfo().AsType();

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SqlSugar
{
/// <summary>
/// Dynamically construct Type, the property is self, with this type
/// </summary>
public class DynamicOneselfType
{
}
/// <summary>
/// Dynamically construct Type, the property is List self , with this type
/// </summary>
public class DynamicOneselfTypeList
{
}
}