mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-11-03 08:55:26 +08:00
- 动态操作表结构相关的 API
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using FreeSql.DataAnnotations;
|
||||
using FreeSql.Internal;
|
||||
|
||||
namespace FreeSql.Extensions
|
||||
{
|
||||
#if net40 || NETSTANDARD2_0
|
||||
#else
|
||||
public static class CodeFirstExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 动态构建Class Type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DynamicCompileBuilder DynamicEntity(this ICodeFirst codeFirst, string className,
|
||||
TableAttribute tableAttribute)
|
||||
{
|
||||
return new DynamicCompileBuilder().SetClass(className, tableAttribute);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using FreeSql;
|
||||
using FreeSql.DataAnnotations;
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.CommonProvider;
|
||||
using FreeSql.Internal.Model;
|
||||
using FreeSql.Internal.ObjectPool;
|
||||
@@ -1299,4 +1300,18 @@ SELECT ");
|
||||
return NativeTuple.Create(query, af, sql);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DynamicEntity
|
||||
#if net40 || NETSTANDARD2_0
|
||||
#else
|
||||
/// <summary>
|
||||
/// 动态构建Class Type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DynamicCompileBuilder DynamicEntity(this ICodeFirst codeFirst, string className, TableAttribute tableAttribute)
|
||||
{
|
||||
return new DynamicCompileBuilder(className, tableAttribute);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
using FreeSql.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DynamicBuilder
|
||||
{
|
||||
#if net40 || NETSTANDARD2_0
|
||||
#else
|
||||
public static class TypeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据动态构建的Class Type生成实例并进行属性赋值
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="porpertys"></param>
|
||||
/// <returns></returns>
|
||||
public static object CreateDynamicEntityInstance(this Type type, IFreeSql fsql,
|
||||
Dictionary<string, object> porpertys)
|
||||
{
|
||||
return DynamicCompileBuilder.CreateObjectByTypeByCodeFirst(fsql, type, porpertys);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置对象属性值
|
||||
/// </summary>
|
||||
/// <param name="fsql"></param>
|
||||
/// <returns></returns>
|
||||
public static void SetPropertyValue(this Type type, IFreeSql fsql, ref object obj, string propertyName,
|
||||
object propertyValue)
|
||||
{
|
||||
var table = fsql.CodeFirst.GetTableByEntity(obj.GetType());
|
||||
table.ColumnsByCs[propertyName].SetValue(obj, propertyValue);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user