From b290d8a2d345c567cba04c7041d8c8781339c198 Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 10:52:03 +0800 Subject: [PATCH 01/11] =?UTF-8?q?-=20DynamicEntity=E6=8B=86=E5=88=86?= =?UTF-8?q?=E7=8B=AC=E7=AB=8Bnuget=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeSql/Internal/DynamicCompileBuilder.cs | 264 ---------------------- 1 file changed, 264 deletions(-) delete mode 100644 FreeSql/Internal/DynamicCompileBuilder.cs diff --git a/FreeSql/Internal/DynamicCompileBuilder.cs b/FreeSql/Internal/DynamicCompileBuilder.cs deleted file mode 100644 index fb4903de..00000000 --- a/FreeSql/Internal/DynamicCompileBuilder.cs +++ /dev/null @@ -1,264 +0,0 @@ -using FreeSql.DataAnnotations; -using System; -using System.Collections; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; -using System.Reflection.Emit; -using System.Security.Cryptography; -using FreeSql.Internal.Model; -using System.Text; - -namespace FreeSql.Internal -{ -#if net40 || NETSTANDARD2_0 -#else - public class DynamicCompileBuilder - { - private string _className = string.Empty; - private Attribute[] _tableAttributes = null; - private List _properties = new List(); - - /// - /// 配置Class - /// - /// 类名 - /// 类标记的特性[Table(Name = "xxx")] - /// - public DynamicCompileBuilder(string className, params Attribute[] attributes) - { - _className = className; - _tableAttributes = attributes; - } - - /// - /// 配置属性 - /// - /// 属性名称 - /// 属性类型 - /// 属性标记的特性-支持多个 - /// - public DynamicCompileBuilder Property(string propertyName, Type propertyType, params Attribute[] attributes) - { - _properties.Add(new DynamicPropertyInfo() - { - PropertyName = propertyName, - PropertyType = propertyType, - Attributes = attributes - }); - return this; - } - - private void SetTableAttribute(ref TypeBuilder typeBuilder) - { - if (_tableAttributes == null) return; - - var propertyValues = new ArrayList(); - foreach (var tableAttribute in _tableAttributes) - { - if (tableAttribute == null) continue; - - var classCtorInfo = tableAttribute.GetType().GetConstructor(new Type[] { }); - var propertyInfos = tableAttribute.GetType().GetProperties().Where(p => p.CanWrite == true).ToArray(); - foreach (var propertyInfo in propertyInfos) - propertyValues.Add(propertyInfo.GetValue(tableAttribute)); - - var customAttributeBuilder = new CustomAttributeBuilder(classCtorInfo, new object[0], propertyInfos, propertyValues.ToArray()); - typeBuilder.SetCustomAttribute(customAttributeBuilder); - } - } - - private void SetPropertys(ref TypeBuilder typeBuilder) - { - foreach (var pinfo in _properties) - { - var propertyName = pinfo.PropertyName; - var propertyType = pinfo?.PropertyType ?? typeof(object); - //设置字段 - var field = typeBuilder.DefineField($"_{FirstCharToLower(propertyName)}", propertyType, - FieldAttributes.Private); - var firstCharToUpper = FirstCharToUpper(propertyName); - //设置属性方法 - var methodGet = typeBuilder.DefineMethod($"Get{firstCharToUpper}", MethodAttributes.Public, - propertyType, null); - var methodSet = typeBuilder.DefineMethod($"Set{firstCharToUpper}", MethodAttributes.Public, null, - new Type[] { propertyType }); - - var ilOfGet = methodGet.GetILGenerator(); - ilOfGet.Emit(OpCodes.Ldarg_0); - ilOfGet.Emit(OpCodes.Ldfld, field); - ilOfGet.Emit(OpCodes.Ret); - - var ilOfSet = methodSet.GetILGenerator(); - ilOfSet.Emit(OpCodes.Ldarg_0); - ilOfSet.Emit(OpCodes.Ldarg_1); - ilOfSet.Emit(OpCodes.Stfld, field); - ilOfSet.Emit(OpCodes.Ret); - - //设置属性 - var propertyBuilder = typeBuilder.DefineProperty(propertyName, PropertyAttributes.None, propertyType, null); - propertyBuilder.SetGetMethod(methodGet); - propertyBuilder.SetSetMethod(methodSet); - - foreach (var pinfoAttribute in pinfo.Attributes) - { - //设置特性 - SetPropertyAttribute(ref propertyBuilder, pinfoAttribute); - } - } - } - - private void SetPropertyAttribute(ref PropertyBuilder propertyBuilder, T tAttribute) - { - if (tAttribute == null) return; - - var propertyInfos = tAttribute.GetType().GetProperties().Where(p => p.CanWrite == true).ToArray(); - var constructor = tAttribute.GetType().GetConstructor(new Type[] { }); - var propertyValues = new ArrayList(); - foreach (var propertyInfo in propertyInfos) - propertyValues.Add(propertyInfo.GetValue(tAttribute)); - - var customAttributeBuilder = new CustomAttributeBuilder(constructor, new object[0], propertyInfos, propertyValues.ToArray()); - propertyBuilder.SetCustomAttribute(customAttributeBuilder); - } - - /// - /// Emit动态创建出Class - Type - /// - /// - public Type Build() - { - //初始化AssemblyName的一个实例 - var assemblyName = new AssemblyName("FreeSql.DynamicCompileBuilder"); - //设置程序集的名称 - var defineDynamicAssembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); - //动态在程序集内创建一个模块 - var defineDynamicModule = - defineDynamicAssembly.DefineDynamicModule("FreeSql.DynamicCompileBuilder.Dynamics"); - //动态的在模块内创建一个类 - var typeBuilder = defineDynamicModule.DefineType(_className, TypeAttributes.Public | TypeAttributes.Class); - - //设置TableAttribute - SetTableAttribute(ref typeBuilder); - - //设置属性 - SetPropertys(ref typeBuilder); - - //创建类的Type对象 - return typeBuilder.CreateType(); - } - - //委托缓存 - private static ConcurrentDictionary - _delegateCache = new ConcurrentDictionary(); - - //设置动态对象的属性值 使用FreeSql自带功能 - public static object CreateObjectByTypeByCodeFirst(IFreeSql fsql, Type type, - Dictionary porpertys) - { - if (type == null) - return null; - object istance = Activator.CreateInstance(type); - if (istance == null) - return null; - var table = fsql.CodeFirst.GetTableByEntity(type); - foreach (var kv in porpertys) - { - table.ColumnsByCs[kv.Key].SetValue(istance, kv.Value); - } - - return istance; - } - - ////设置动态对象的属性值,使用表达式目录树 - //public static object CreateObjectByType(Type type, Dictionary porpertys) - //{ - // if (type == null) - // return null; - // object istance = Activator.CreateInstance(type); - // if (istance == null) - // return null; - // //根据字典中的key确定缓存 - // var cacheKeyStr = string.Join("-", porpertys.Keys.OrderBy(s => s)); - // var cacheKey = Md5Encryption(cacheKeyStr); - // var dynamicDelegate = _delegateCache.GetOrAdd(cacheKey, key => - // { - // //表达式目录树构建委托 - // var typeParam = Expression.Parameter(type); - // var dicParamType = typeof(Dictionary); - // var dicParam = Expression.Parameter(dicParamType); - // var exps = new List(); - // var tempRef = Expression.Variable(typeof(object)); - // foreach (var pinfo in porpertys) - // { - // var propertyInfo = type.GetProperty(pinfo.Key); - // if (propertyInfo == null) - // continue; - // var propertyName = Expression.Constant(pinfo.Key, typeof(string)); - // exps.Add(Expression.Call(dicParam, dicParamType.GetMethod("TryGetValue"), propertyName, tempRef)); - // exps.Add(Expression.Assign(Expression.MakeMemberAccess(typeParam, propertyInfo), - // Expression.Convert(tempRef, propertyInfo.PropertyType))); - // exps.Add(Expression.Assign(tempRef, Expression.Default(typeof(object)))); - // } - - // var returnTarget = Expression.Label(type); - // exps.Add(Expression.Return(returnTarget, typeParam)); - // exps.Add(Expression.Label(returnTarget, Expression.Default(type))); - // var block = Expression.Block(new[] { tempRef }, exps); - // var @delegate = Expression.Lambda(block, typeParam, dicParam).Compile(); - // return @delegate; - // }); - // var dynamicInvoke = dynamicDelegate.DynamicInvoke(istance, porpertys); - // return dynamicInvoke; - //} - - /// - /// 首字母小写 - /// - /// - /// - private string FirstCharToLower(string input) - { - if (string.IsNullOrEmpty(input)) - return input; - string str = input.First().ToString().ToLower() + input.Substring(1); - return str; - } - - /// - /// 首字母大写 - /// - /// - /// - private string FirstCharToUpper(string input) - { - if (string.IsNullOrEmpty(input)) - return input; - string str = input.First().ToString().ToUpper() + input.Substring(1); - return str; - } - - private static string Md5Encryption(string inputStr) - { - var result = string.Empty; - //32位大写 - using (var md5 = MD5.Create()) - { - var resultBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(inputStr)); - result = BitConverter.ToString(resultBytes); - } - - return result; - } - - class DynamicPropertyInfo - { - public string PropertyName { get; set; } = string.Empty; - public Type PropertyType { get; set; } - public Attribute[] Attributes { get; set; } - } - } -#endif -} \ No newline at end of file From 64c9d0bdee84bba3fb5d965f57f7fcd80446b297 Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 10:52:52 +0800 Subject: [PATCH 02/11] =?UTF-8?q?-=20DynamicEntity=E6=8B=86=E5=88=86?= =?UTF-8?q?=E7=8B=AC=E7=AB=8Bnuget=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeSql/Extensions/FreeSqlGlobalExtensions.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/FreeSql/Extensions/FreeSqlGlobalExtensions.cs b/FreeSql/Extensions/FreeSqlGlobalExtensions.cs index 06db0959..786e1803 100644 --- a/FreeSql/Extensions/FreeSqlGlobalExtensions.cs +++ b/FreeSql/Extensions/FreeSqlGlobalExtensions.cs @@ -1301,17 +1301,4 @@ SELECT "); } #endregion - #region DynamicEntity -#if net40 || NETSTANDARD2_0 -#else - /// - /// 动态构建Class Type - /// - /// - public static DynamicCompileBuilder DynamicEntity(this ICodeFirst codeFirst, string className, TableAttribute tableAttribute) - { - return new DynamicCompileBuilder(className, tableAttribute); - } -#endif - #endregion } From b17c2ef4a5bfe6bd44fe8eacd2595212df0f0072 Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 10:53:28 +0800 Subject: [PATCH 03/11] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0DynamicEntity?= =?UTF-8?q?=E7=AB=8Bnuget=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DynamicCompileBuilder.cs | 231 ++++++++++++++++++ .../DynamicCompileHelper.cs | 74 ++++++ .../FreeSql.Extensions.DynamicEntity.csproj | 15 ++ .../FreeSql.Extensions.DynamicEntity.xml | 81 ++++++ 4 files changed, 401 insertions(+) create mode 100644 Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileBuilder.cs create mode 100644 Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileHelper.cs create mode 100644 Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.csproj create mode 100644 Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.xml diff --git a/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileBuilder.cs b/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileBuilder.cs new file mode 100644 index 00000000..cbea309a --- /dev/null +++ b/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileBuilder.cs @@ -0,0 +1,231 @@ +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using System.Reflection.Emit; +using System.Security.Cryptography; +using System.Text; + +namespace FreeSql +{ + /// + /// 动态创建实体类型 + /// + public class DynamicCompileBuilder + { + private string _className = string.Empty; + private Attribute[] _tableAttributes = null; + private List _properties = new List(); + private Type _superClass = null; + + /// + /// 配置Class + /// + /// 类名 + /// 类标记的特性[Table(Name = "xxx")] [Index(xxxx)] + /// + public DynamicCompileBuilder Class(string className, params Attribute[] attributes) + { + _className = className; + _tableAttributes = attributes; + return this; + } + + /// + /// 配置属性 + /// + /// 属性名称 + /// 属性类型 + /// 属性标记的特性-支持多个 + /// + public DynamicCompileBuilder Property(string propertyName, Type propertyType, params Attribute[] attributes) + { + _properties.Add(new DynamicPropertyInfo() + { + PropertyName = propertyName, + PropertyType = propertyType, + Attributes = attributes + }); + return this; + } + + /// + /// 配置父类 + /// + /// 父类类型 + /// + public DynamicCompileBuilder SuperClass(Type superClass) + { + _superClass = superClass; + return this; + } + + private void SetTableAttribute(ref TypeBuilder typeBuilder) + { + if (_tableAttributes == null) return; + + foreach (var tableAttribute in _tableAttributes) + { + var propertyValues = new ArrayList(); + + if (tableAttribute == null) continue; + + var classCtorInfo = tableAttribute.GetType().GetConstructor(new Type[] { }); + + var propertyInfos = tableAttribute.GetType().GetProperties().Where(p => p.CanWrite == true).ToArray(); + + foreach (var propertyInfo in propertyInfos) + propertyValues.Add(propertyInfo.GetValue(tableAttribute)); + + //可能存在有参构造 + if (classCtorInfo == null) + { + var constructorTypes = propertyInfos.Select(p => p.PropertyType); + classCtorInfo = tableAttribute.GetType().GetConstructor(constructorTypes.ToArray()); + var customAttributeBuilder = new CustomAttributeBuilder(classCtorInfo, propertyValues.ToArray()); + typeBuilder.SetCustomAttribute(customAttributeBuilder); + } + else + { + var customAttributeBuilder = new CustomAttributeBuilder(classCtorInfo, new object[0], propertyInfos, + propertyValues.ToArray()); + typeBuilder.SetCustomAttribute(customAttributeBuilder); + } + } + } + + private void SetPropertys(ref TypeBuilder typeBuilder) + { + foreach (var pinfo in _properties) + { + if (pinfo == null) + continue; + var propertyName = pinfo.PropertyName; + var propertyType = pinfo.PropertyType; + //设置字段 + var field = typeBuilder.DefineField($"_{FirstCharToLower(propertyName)}", propertyType, + FieldAttributes.Private); + var firstCharToUpper = FirstCharToUpper(propertyName); + //设置属性方法 + var methodGet = typeBuilder.DefineMethod($"Get{firstCharToUpper}", MethodAttributes.Public, + propertyType, null); + var methodSet = typeBuilder.DefineMethod($"Set{firstCharToUpper}", MethodAttributes.Public, null, + new Type[] { propertyType }); + + var ilOfGet = methodGet.GetILGenerator(); + ilOfGet.Emit(OpCodes.Ldarg_0); + ilOfGet.Emit(OpCodes.Ldfld, field); + ilOfGet.Emit(OpCodes.Ret); + + var ilOfSet = methodSet.GetILGenerator(); + ilOfSet.Emit(OpCodes.Ldarg_0); + ilOfSet.Emit(OpCodes.Ldarg_1); + ilOfSet.Emit(OpCodes.Stfld, field); + ilOfSet.Emit(OpCodes.Ret); + + //设置属性 + var propertyBuilder = + typeBuilder.DefineProperty(propertyName, PropertyAttributes.None, propertyType, null); + propertyBuilder.SetGetMethod(methodGet); + propertyBuilder.SetSetMethod(methodSet); + + foreach (var pinfoAttribute in pinfo.Attributes) + { + //设置特性 + SetPropertyAttribute(ref propertyBuilder, pinfoAttribute); + } + } + } + + private void SetPropertyAttribute(ref PropertyBuilder propertyBuilder, T tAttribute) + { + if (tAttribute == null) return; + + var propertyInfos = tAttribute.GetType().GetProperties().Where(p => p.CanWrite == true).ToArray(); + var constructor = tAttribute.GetType().GetConstructor(new Type[] { }); + var propertyValues = new ArrayList(); + foreach (var propertyInfo in propertyInfos) + propertyValues.Add(propertyInfo.GetValue(tAttribute)); + + var customAttributeBuilder = + new CustomAttributeBuilder(constructor, new object[0], propertyInfos, propertyValues.ToArray()); + propertyBuilder.SetCustomAttribute(customAttributeBuilder); + } + + /// + /// Emit动态创建出Class - Type + /// + /// + public Type Build() + { + //初始化AssemblyName的一个实例 + var assemblyName = new AssemblyName("FreeSql.DynamicCompileBuilder"); + //设置程序集的名称 + var defineDynamicAssembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); + //动态在程序集内创建一个模块 + var defineDynamicModule = + defineDynamicAssembly.DefineDynamicModule("FreeSql.DynamicCompileBuilder.Dynamics"); + //动态的在模块内创建一个类 + var typeBuilder = + defineDynamicModule.DefineType(_className, TypeAttributes.Public | TypeAttributes.Class, _superClass); + + //设置TableAttribute + SetTableAttribute(ref typeBuilder); + + //设置属性 + SetPropertys(ref typeBuilder); + + //创建类的Type对象 + return typeBuilder.CreateType(); + } + + /// + /// 首字母小写 + /// + /// + /// + private string FirstCharToLower(string input) + { + if (string.IsNullOrEmpty(input)) + return input; + string str = input.First().ToString().ToLower() + input.Substring(1); + return str; + } + + /// + /// 首字母大写 + /// + /// + /// + private string FirstCharToUpper(string input) + { + if (string.IsNullOrEmpty(input)) + return input; + string str = input.First().ToString().ToUpper() + input.Substring(1); + return str; + } + + private static string Md5Encryption(string inputStr) + { + var result = string.Empty; + //32位大写 + using (var md5 = MD5.Create()) + { + var resultBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(inputStr)); + result = BitConverter.ToString(resultBytes); + } + + return result; + } + + class DynamicPropertyInfo + { + public string PropertyName { get; set; } = string.Empty; + public Type PropertyType { get; set; } + public Attribute[] Attributes { get; set; } + } + } +} \ No newline at end of file diff --git a/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileHelper.cs b/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileHelper.cs new file mode 100644 index 00000000..5e839e06 --- /dev/null +++ b/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileHelper.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq.Expressions; + +namespace FreeSql.Extensions.DynamicEntity +{ + /// + /// 动态创建对象帮助类 + /// + public class DynamicCompileHelper + { + /// + /// 动态构建Class - Type + /// + /// + public static DynamicCompileBuilder DynamicBuilder() + { + return new DynamicCompileBuilder(); + } + + /// + /// 委托缓存 + /// + private static readonly ConcurrentDictionary + DelegateCache = new ConcurrentDictionary(); + + /// + /// 设置动态对象的属性值 + /// + /// + /// + /// + public static object CreateObjectByType(Type type, Dictionary porpertys) + { + if (type == null) + return null; + object istance = Activator.CreateInstance(type); + if (istance == null) + return null; + //根据key确定缓存 + var cacheKey = $"{type.GetHashCode()}{porpertys.GetHashCode()}"; + var dynamicDelegate = DelegateCache.GetOrAdd(cacheKey, key => + { + //表达式目录树构建委托 + var typeParam = Expression.Parameter(type); + var dicParamType = typeof(Dictionary); + var dicParam = Expression.Parameter(dicParamType); + var exps = new List(); + var tempRef = Expression.Variable(typeof(object)); + foreach (var pinfo in porpertys) + { + var propertyInfo = type.GetProperty(pinfo.Key); + if (propertyInfo == null) + continue; + var propertyName = Expression.Constant(pinfo.Key, typeof(string)); + exps.Add(Expression.Call(dicParam, dicParamType.GetMethod("TryGetValue"), propertyName, tempRef)); + exps.Add(Expression.Assign(Expression.MakeMemberAccess(typeParam, propertyInfo), + Expression.Convert(tempRef, propertyInfo.PropertyType))); + exps.Add(Expression.Assign(tempRef, Expression.Default(typeof(object)))); + } + + var returnTarget = Expression.Label(type); + exps.Add(Expression.Return(returnTarget, typeParam)); + exps.Add(Expression.Label(returnTarget, Expression.Default(type))); + var block = Expression.Block(new[] { tempRef }, exps); + var @delegate = Expression.Lambda(block, typeParam, dicParam).Compile(); + return @delegate; + }); + var dynamicInvoke = dynamicDelegate.DynamicInvoke(istance, porpertys); + return dynamicInvoke; + } + } +} \ No newline at end of file diff --git a/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.csproj b/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.csproj new file mode 100644 index 00000000..c1b359b8 --- /dev/null +++ b/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.csproj @@ -0,0 +1,15 @@ + + + + netstandard2.1;net451;net45; + True + FreeSql.Extensions.DynamicEntity.xml + + + + + Always + + + + diff --git a/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.xml b/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.xml new file mode 100644 index 00000000..b5032f3a --- /dev/null +++ b/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.xml @@ -0,0 +1,81 @@ + + + + FreeSql.Extensions.DynamicEntity + + + + + 动态创建实体类型 + + + + + 配置Class + + 类名 + 类标记的特性[Table(Name = "xxx")] [Index(xxxx)] + + + + + 配置属性 + + 属性名称 + 属性类型 + 属性标记的特性-支持多个 + + + + + 配置父类 + + 父类类型 + + + + + Emit动态创建出Class - Type + + + + + + 首字母小写 + + + + + + + 首字母大写 + + + + + + + 动态创建对象帮助类 + + + + + 动态构建Class - Type + + + + + + 委托缓存 + + + + + 设置动态对象的属性值 + + + + + + + From 785d204a2ce3df1a5d9c532059c11247a6c9bf52 Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 10:59:05 +0800 Subject: [PATCH 04/11] =?UTF-8?q?-=20FreeSql.Extensions.DynamicEntity?= =?UTF-8?q?=E5=8C=85=E4=BF=A1=E6=81=AF=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FreeSql.Extensions.DynamicEntity.csproj | 49 ++++++++++++++---- .../FreeSql.Extensions.DynamicEntity/key.snk | Bin 0 -> 596 bytes 2 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 Extensions/FreeSql.Extensions.DynamicEntity/key.snk diff --git a/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.csproj b/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.csproj index c1b359b8..321f8a2d 100644 --- a/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.csproj +++ b/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.csproj @@ -1,15 +1,42 @@  - - netstandard2.1;net451;net45; - True - FreeSql.Extensions.DynamicEntity.xml - + + netstandard2.1;net451;net45; + True + true + FreeSql;ncc;YeXiangQin;Daily + FreeSql 扩展包,可实现动态构建实体类,动态创建表. + https://github.com/2881099/FreeSql + https://github.com/2881099/FreeSql + git + MIT + FreeSql;ORM + $(AssemblyName) + logo.png + $(AssemblyName) + true + true + true + key.snk + false + 3.2.694 $(AssemblyName) + logo.png + $(AssemblyName) + true + true + true + key.snk + false + FreeSql.Extensions.DynamicEntity.xml + + + + - - - Always - - + + + Always + + - + \ No newline at end of file diff --git a/Extensions/FreeSql.Extensions.DynamicEntity/key.snk b/Extensions/FreeSql.Extensions.DynamicEntity/key.snk new file mode 100644 index 0000000000000000000000000000000000000000..e580bc8d5d64e7c5a0c62b971545d38cfbe7d837 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096c(W3|+clf|4d2=6Xc+R`Gd@9@k@Meh} zR8`}1=JPk=q?Zlr?i$1O?SgX-{{&z z|LRF?-aWODhAO}h_7M!wz}uPXx}n-g{((r9{{%_ z4)%gVXcj;Ru@GYAIZI@e#GBtO#O5m-Qr4X_lbAV}=qNRkd0^`@I6i9k`wSe@ZPxVo zk;MXig(S-cYHE!0GWWlp7EH@E!WkF6jS+3z4rvW0%Sq;U1bq`B9*HNJjxo*23*7Vw zHyt>{2CR~8==`lYLgAmwsXPXYZ_AEAKy|PuUz0(G)L1xO{{*n6Bn?mV~QKg!055THihpc>GOh(U-NgO?4_DzY4uq!p9=Q;`G i9;v3GkC674Mbx4_b$)?7a0%Z%&zUjzbGs@!l^s|B literal 0 HcmV?d00001 From 52ce785002ab2f211f62f9ba545da04ab0d73b3e Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 11:03:42 +0800 Subject: [PATCH 05/11] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0DynamicEntity?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs diff --git a/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs b/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs new file mode 100644 index 00000000..9e71b207 --- /dev/null +++ b/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FreeSql.Tests.DynamicEntity +{ + internal class DynamicEntityTest + { + } +} From 6b86fc46bd6926e605de0abf8a8fc1388e9786dd Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 11:06:41 +0800 Subject: [PATCH 06/11] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0DynamicEntity=20-?= =?UTF-8?q?=20Attribute=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DynamicEntity/DynamicEntityTest.cs | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs b/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs index 9e71b207..8b80a2fc 100644 --- a/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs @@ -3,10 +3,62 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using FreeSql.DataAnnotations; +using FreeSql.Extensions.DynamicEntity; +using Xunit; namespace FreeSql.Tests.DynamicEntity { - internal class DynamicEntityTest + public class DynamicEntityTest { + private static IFreeSql fsql = new FreeSqlBuilder().UseConnectionString(DataType.PostgreSQL, + "Host=192.168.0.36;Port=5432;Username=postgres;Password=123; Database=test;ArrayNullabilityMode=Always;Pooling=true;Minimum Pool Size=1") + .UseMonitorCommand(d => Console.WriteLine(d.CommandText)).Build(); + + + [Fact] + public void NormalTest() + { + Type type = DynamicCompileHelper.DynamicBuilder() + .Class("NormalUsers") + .Property("Id", typeof(int)) + .Property("Name", typeof(string)) + .Property("Address", typeof(string)) + .Build(); + var dict = new Dictionary + { + ["Name"] = "张三", + ["Id"] = 1, + ["Address"] = "北京市" + }; + var instance = DynamicCompileHelper.CreateObjectByType(type, dict); + //根据Type生成表 + fsql.CodeFirst.SyncStructure(type); + fsql.Insert().AsType(type).AppendData(instance).ExecuteAffrows(); + } + + [Fact] + public void AttributeTest() + { + Type type = DynamicCompileHelper.DynamicBuilder() + .Class("AttributeUsers", new TableAttribute() { Name = "T_Attribute_User" }, + new IndexAttribute("Name_Index", "Name", false)) + .Property("Id", typeof(int), + new ColumnAttribute() { IsPrimary = true, IsIdentity = true, Position = 1 }) + .Property("Name", typeof(string), + new ColumnAttribute() { StringLength = 20, Position = 2 }) + .Property("Address", typeof(string), + new ColumnAttribute() { StringLength = 150, Position = 3 }) + .Build(); + var dict = new Dictionary + { + ["Name"] = "张三", + ["Address"] = "北京市" + }; + var instance = DynamicCompileHelper.CreateObjectByType(type, dict); + //根据Type生成表 + fsql.CodeFirst.SyncStructure(type); + fsql.Insert().AsType(type).AppendData(instance).ExecuteAffrows(); + } } -} +} \ No newline at end of file From 4e36d6ca204921c3eb28908f0c20b111b9a74c55 Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 11:19:09 +0800 Subject: [PATCH 07/11] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0DynamicEntity=20-?= =?UTF-8?q?=20SuperClass=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DynamicEntity/DynamicEntityTest.cs | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs b/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs index 8b80a2fc..c3638f85 100644 --- a/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs @@ -21,14 +21,14 @@ namespace FreeSql.Tests.DynamicEntity { Type type = DynamicCompileHelper.DynamicBuilder() .Class("NormalUsers") - .Property("Id", typeof(int)) + .Property("Id", typeof(string)) .Property("Name", typeof(string)) .Property("Address", typeof(string)) .Build(); var dict = new Dictionary { ["Name"] = "张三", - ["Id"] = 1, + ["Id"] = Guid.NewGuid().ToString(), ["Address"] = "北京市" }; var instance = DynamicCompileHelper.CreateObjectByType(type, dict); @@ -58,7 +58,46 @@ namespace FreeSql.Tests.DynamicEntity var instance = DynamicCompileHelper.CreateObjectByType(type, dict); //根据Type生成表 fsql.CodeFirst.SyncStructure(type); + var insertId = fsql.Insert().AsType(type).AppendData(instance).ExecuteIdentity(); + var select = fsql.Select().AsType(type).ToList(); + } + + [Fact] + public void SuperClassTest() + { + Type type = DynamicCompileHelper.DynamicBuilder() + .Class("Roles", new TableAttribute() { Name = "T_Role" }, + new IndexAttribute("Name_Index", "Name", false)) + .SuperClass(typeof(BaseModel)) + .Property("Id", typeof(int), + new ColumnAttribute() { IsPrimary = true, IsIdentity = true, Position = 1 }) + .Property("Name", typeof(string), + new ColumnAttribute() { StringLength = 20, Position = 2 }) + .Build(); + var dict = new Dictionary + { + ["Name"] = "系统管理员", + ["UpdateTime"] = DateTime.Now, + ["UpdatePerson"] = "admin" + }; + var instance = DynamicCompileHelper.CreateObjectByType(type, dict); + //根据Type生成表 + fsql.CodeFirst.SyncStructure(type); fsql.Insert().AsType(type).AppendData(instance).ExecuteAffrows(); } } + public class BaseModel + { + [Column(Position = 99)] + public DateTime UpdateTime + { + get; set; + } + + [Column(Position = 100, StringLength = 20)] + public string UpdatePerson + { + get; set; + } + } } \ No newline at end of file From fa20468dc8dbf032ea407528faea6662c12c68e5 Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 11:19:56 +0800 Subject: [PATCH 08/11] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0DynamicEntity?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeSql.Tests/FreeSql.Tests/FreeSql.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/FreeSql.Tests/FreeSql.Tests/FreeSql.Tests.csproj b/FreeSql.Tests/FreeSql.Tests/FreeSql.Tests.csproj index 79602ff3..d9745794 100644 --- a/FreeSql.Tests/FreeSql.Tests/FreeSql.Tests.csproj +++ b/FreeSql.Tests/FreeSql.Tests/FreeSql.Tests.csproj @@ -35,6 +35,7 @@ + From 18cd0e7a281cffbaee1102872a25403c7602f821 Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 11:44:12 +0800 Subject: [PATCH 09/11] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96DynamicEntity?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=8A=A8=E6=80=81=E5=AF=B9=E8=B1=A1=E7=9A=84?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=80=BC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DynamicCompileBuilder.cs | 6 ++--- .../DynamicCompileHelper.cs | 24 ++++++++++++++++--- .../FreeSql.Extensions.DynamicEntity.xml | 14 +++++------ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileBuilder.cs b/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileBuilder.cs index cbea309a..be1bbf0e 100644 --- a/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileBuilder.cs +++ b/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileBuilder.cs @@ -1,15 +1,13 @@ using System; using System.Collections; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Security.Cryptography; using System.Text; -namespace FreeSql +namespace FreeSql.Extensions.DynamicEntity { /// /// 动态创建实体类型 @@ -57,7 +55,7 @@ namespace FreeSql /// /// 父类类型 /// - public DynamicCompileBuilder SuperClass(Type superClass) + public DynamicCompileBuilder Extend(Type superClass) { _superClass = superClass; return this; diff --git a/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileHelper.cs b/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileHelper.cs index 5e839e06..dec44591 100644 --- a/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileHelper.cs +++ b/Extensions/FreeSql.Extensions.DynamicEntity/DynamicCompileHelper.cs @@ -1,7 +1,10 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Linq; using System.Linq.Expressions; +using System.Security.Cryptography; +using System.Text; namespace FreeSql.Extensions.DynamicEntity { @@ -22,8 +25,8 @@ namespace FreeSql.Extensions.DynamicEntity /// /// 委托缓存 /// - private static readonly ConcurrentDictionary - DelegateCache = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary DelegateCache = + new ConcurrentDictionary(); /// /// 设置动态对象的属性值 @@ -39,7 +42,9 @@ namespace FreeSql.Extensions.DynamicEntity if (istance == null) return null; //根据key确定缓存 - var cacheKey = $"{type.GetHashCode()}{porpertys.GetHashCode()}"; + var cacheKeyStr = string.Join("-", porpertys.Keys.OrderBy(s => s)); + var dicKey = Md5Encryption(cacheKeyStr); + var cacheKey = $"{type.GetHashCode()}-{dicKey}"; var dynamicDelegate = DelegateCache.GetOrAdd(cacheKey, key => { //表达式目录树构建委托 @@ -70,5 +75,18 @@ namespace FreeSql.Extensions.DynamicEntity var dynamicInvoke = dynamicDelegate.DynamicInvoke(istance, porpertys); return dynamicInvoke; } + + private static string Md5Encryption(string inputStr) + { + var result = string.Empty; + //32位大写 + using (var md5 = MD5.Create()) + { + var resultBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(inputStr)); + result = BitConverter.ToString(resultBytes); + } + + return result; + } } } \ No newline at end of file diff --git a/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.xml b/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.xml index b5032f3a..a2ae1e55 100644 --- a/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.xml +++ b/Extensions/FreeSql.Extensions.DynamicEntity/FreeSql.Extensions.DynamicEntity.xml @@ -4,12 +4,12 @@ FreeSql.Extensions.DynamicEntity - + 动态创建实体类型 - + 配置Class @@ -17,7 +17,7 @@ 类标记的特性[Table(Name = "xxx")] [Index(xxxx)] - + 配置属性 @@ -26,27 +26,27 @@ 属性标记的特性-支持多个 - + 配置父类 父类类型 - + Emit动态创建出Class - Type - + 首字母小写 - + 首字母大写 From c761e45b922ce70263e350023781f67880ac7e23 Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 11:46:48 +0800 Subject: [PATCH 10/11] =?UTF-8?q?-=20DynamicEntity=E6=8B=86=E5=88=86?= =?UTF-8?q?=E7=8B=AC=E7=AB=8Bnuget=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeSql.sln | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/FreeSql.sln b/FreeSql.sln index e20ed226..4dd2b5f1 100644 --- a/FreeSql.sln +++ b/FreeSql.sln @@ -125,6 +125,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Provider.Xugu", "Pr EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Provider.Xugu", "FreeSql.Tests\FreeSql.Tests.Provider.Xugu\FreeSql.Tests.Provider.Xugu.csproj", "{16C21D77-20AC-4722-AD97-F53BDDE8210C}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Extensions.DynamicEntity", "Extensions\FreeSql.Extensions.DynamicEntity\FreeSql.Extensions.DynamicEntity.csproj", "{FC4639EC-7787-4F85-AC02-26875E39E573}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -747,6 +749,18 @@ Global {16C21D77-20AC-4722-AD97-F53BDDE8210C}.Release|x64.Build.0 = Release|Any CPU {16C21D77-20AC-4722-AD97-F53BDDE8210C}.Release|x86.ActiveCfg = Release|Any CPU {16C21D77-20AC-4722-AD97-F53BDDE8210C}.Release|x86.Build.0 = Release|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|x64.ActiveCfg = Debug|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|x64.Build.0 = Debug|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|x86.ActiveCfg = Debug|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Debug|x86.Build.0 = Debug|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Release|Any CPU.Build.0 = Release|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Release|x64.ActiveCfg = Release|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Release|x64.Build.0 = Release|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Release|x86.ActiveCfg = Release|Any CPU + {FC4639EC-7787-4F85-AC02-26875E39E573}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -787,6 +801,7 @@ Global {8A06B18A-A8BF-4AEA-AFE4-0F573C2DBFEE} = {2A381C57-2697-427B-9F10-55DA11FD02E4} {71A6F937-D11B-4AE4-9933-BB6B4D925665} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA} {8064870C-22EA-4A58-972D-DBD57D096D91} = {2A381C57-2697-427B-9F10-55DA11FD02E4} + {FC4639EC-7787-4F85-AC02-26875E39E573} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution RESX_NeutralResourcesLanguage = en-US From d26ad21833f41dd21781a0dd11a16c219b0222c5 Mon Sep 17 00:00:00 2001 From: d4ilys <963922242@qq.com> Date: Fri, 5 May 2023 11:52:18 +0800 Subject: [PATCH 11/11] =?UTF-8?q?-=20=E8=B0=83=E6=95=B4DynamicEntity?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DynamicEntity/DynamicEntityTest.cs | 3 +- FreeSql/FreeSql.xml | 43 ------------------- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs b/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs index c3638f85..77579f8c 100644 --- a/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/DynamicEntity/DynamicEntityTest.cs @@ -15,7 +15,6 @@ namespace FreeSql.Tests.DynamicEntity "Host=192.168.0.36;Port=5432;Username=postgres;Password=123; Database=test;ArrayNullabilityMode=Always;Pooling=true;Minimum Pool Size=1") .UseMonitorCommand(d => Console.WriteLine(d.CommandText)).Build(); - [Fact] public void NormalTest() { @@ -68,7 +67,7 @@ namespace FreeSql.Tests.DynamicEntity Type type = DynamicCompileHelper.DynamicBuilder() .Class("Roles", new TableAttribute() { Name = "T_Role" }, new IndexAttribute("Name_Index", "Name", false)) - .SuperClass(typeof(BaseModel)) + .Extend(typeof(BaseModel)) .Property("Id", typeof(int), new ColumnAttribute() { IsPrimary = true, IsIdentity = true, Position = 1 }) .Property("Name", typeof(string), diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml index 1eab8ccc..5323d7da 100644 --- a/FreeSql/FreeSql.xml +++ b/FreeSql/FreeSql.xml @@ -4248,43 +4248,6 @@ Dict:key=属性名,value=注释 - - - 配置Class - - 类名 - 类标记的特性[Table(Name = "xxx")] - - - - - 配置属性 - - 属性名称 - 属性类型 - 属性标记的特性-支持多个 - - - - - Emit动态创建出Class - Type - - - - - - 首字母小写 - - - - - - - 首字母大写 - - - - 更新实体的元数据 @@ -5906,12 +5869,6 @@ - - - 动态构建Class Type - - - 使用 and 拼接两个 lambda 表达式