调整CodeFirst扩展方法

This commit is contained in:
d4ilys 2023-04-25 10:26:39 +08:00
parent 39feb64646
commit c012c166d8

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using System.Text; using System.Text;
using FreeSql.DataAnnotations; using FreeSql.DataAnnotations;
using FreeSql.Internal; using FreeSql.Internal;
@ -7,7 +8,6 @@ using FreeSql.Internal;
namespace FreeSql.Extensions namespace FreeSql.Extensions
{ {
#if net40 || NETSTANDARD2_0 #if net40 || NETSTANDARD2_0
//不支持
#else #else
public static class CodeFirstExtensions public static class CodeFirstExtensions
{ {
@ -15,22 +15,12 @@ namespace FreeSql.Extensions
/// 动态构建Class Type /// 动态构建Class Type
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static DynamicCompileBuilder DynamicEntity(this ICodeFirst codeFirst, string className, TableAttribute tableAttribute) public static DynamicCompileBuilder DynamicEntity(this ICodeFirst codeFirst, string className,
TableAttribute tableAttribute)
{ {
return new DynamicCompileBuilder().SetClass(className, tableAttribute); return new DynamicCompileBuilder().SetClass(className, tableAttribute);
} }
/// <summary>
/// 根据动态构建的Class Type生成实例并进行属性赋值
/// </summary>
/// <param name="type"></param>
/// <param name="porpertys"></param>
/// <returns></returns>
public static object CreateDynamicEntityInstance(this Type type,
Dictionary<string, object> porpertys)
{
return DynamicCompileBuilder.CreateObjectByType(type, porpertys);
}
} }
#endif #endif
} }