增加动态创建实体API

This commit is contained in:
d4ilys
2023-04-24 14:28:45 +08:00
parent 91da92b11f
commit 43a8e8bee9
3 changed files with 73 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using FreeSql.DataAnnotations;
using FreeSql.Internal;
namespace FreeSql.Extensions
@@ -14,9 +15,9 @@ namespace FreeSql.Extensions
/// 动态创建Class Type
/// </summary>
/// <returns></returns>
public static DynamicCompileBuilder DynamicBuilder(this ICodeFirst codeFirst)
public static DynamicCompileBuilder DynamicEntity(this ICodeFirst codeFirst, string className, TableAttribute tableAttribute)
{
return new DynamicCompileBuilder();
return new DynamicCompileBuilder().SetClass(className, tableAttribute);
}
/// <summary>
@@ -25,7 +26,7 @@ namespace FreeSql.Extensions
/// <param name="type"></param>
/// <param name="porpertys"></param>
/// <returns></returns>
public static object CreateObjectByType(this ICodeFirst codeFirst, Type type,
public static object CreateDynamicEntityInstance(this Type type,
Dictionary<string, object> porpertys)
{
return DynamicCompileBuilder.CreateObjectByType(type, porpertys);