mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-11-03 08:55:26 +08:00
增加动态创建实体API
This commit is contained in:
35
FreeSql/Extensions/CodeFirstExtensions.cs
Normal file
35
FreeSql/Extensions/CodeFirstExtensions.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using FreeSql.Internal;
|
||||
|
||||
namespace FreeSql.Extensions
|
||||
{
|
||||
#if net40 || NETSTANDARD2_0
|
||||
//不支持
|
||||
#else
|
||||
public static class CodeFirstExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 动态创建Class Type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DynamicCompileBuilder DynamicBuilder(this ICodeFirst codeFirst)
|
||||
{
|
||||
return new DynamicCompileBuilder();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据动态构建的Class生成实例并进行属性赋值
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="porpertys"></param>
|
||||
/// <returns></returns>
|
||||
public static object CreateObjectByType(this ICodeFirst codeFirst, Type type,
|
||||
Dictionary<string, object> porpertys)
|
||||
{
|
||||
return DynamicCompileBuilder.CreateObjectByType(type, porpertys);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user