update

2881099
2020-12-04 00:09:49 +08:00
parent 518a513059
commit b55ded9c05

@@ -128,26 +128,16 @@ var t2 = fsql.CodeFirst.SyncStructure<Topic>();
1.扫描 IEntity类所在程序集反射得到类上有特性标签为TableAttribute 的所有类,该方法需在实体类上指定了 [Table(Name = "xxx")]特性标签
```c#
public class ReflexHelper
public static Type[] GetTypesByTableAttribute()
{
public static Type[] GetTypesByTableAttribute()
{
List<Type> tableAssembies = new List<Type>();
foreach (Type type in Assembly.GetAssembly(typeof(IEntity)).GetExportedTypes())
{
foreach (Attribute attribute in type.GetCustomAttributes())
{
if (attribute is TableAttribute tableAttribute)
{
if (tableAttribute.DisableSyncStructure == false)
{
tableAssembies.Add(type);
}
}
}
};
return tableAssembies.ToArray();
}
List<Type> tableAssembies = new List<Type>();
foreach (Type type in Assembly.GetAssembly(typeof(IEntity)).GetExportedTypes())
foreach (Attribute attribute in type.GetCustomAttributes())
if (attribute is TableAttribute tableAttribute)
if (tableAttribute.DisableSyncStructure == false)
tableAssembies.Add(type);
return tableAssembies.ToArray();
}
```
调用
@@ -166,18 +156,11 @@ public static Type[] GetTypesByNameSpace()
"LinCms.Entities.Settings",
"LinCms.Entities.Base",
};
foreach (Type type in Assembly.GetAssembly(typeof(IEntity)).GetExportedTypes())
{
foreach (var fullname in entitiesFullName)
{
if (type.FullName.StartsWith(fullname) && type.IsClass)
{
tableAssembies.Add(type);
}
}
}
return tableAssembies.ToArray();
}
```