|
|
|
@ -65,6 +65,13 @@ namespace Apewer.Source |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 自定义
|
|
|
|
|
|
|
|
/// <summary>根据类型自定义表名。</summary>
|
|
|
|
public static Func<Type, string> CustomTableName { get; set; } |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region cache
|
|
|
|
|
|
|
|
private static Dictionary<string, TableAttribute> _tac = new Dictionary<string, TableAttribute>(); |
|
|
|
@ -106,7 +113,19 @@ namespace Apewer.Source |
|
|
|
} |
|
|
|
|
|
|
|
ta._model = type; |
|
|
|
if (string.IsNullOrEmpty(ta.Name)) ta._name = type.Name; |
|
|
|
if (string.IsNullOrEmpty(ta.Name)) |
|
|
|
{ |
|
|
|
if (CustomTableName == null) |
|
|
|
{ |
|
|
|
ta._name = type.Name; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ta._name = CustomTableName.Invoke(type); |
|
|
|
if (string.IsNullOrEmpty(ta._name)) throw new ArgumentException($"CustomTableName 未返回类型 {type.Name} 的表名。"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
ta.Independent = RuntimeUtility.Contains<IndependentAttribute>(type, true); |
|
|
|
ta._primarykey = RuntimeUtility.IsInherits(type, InterfacePrimaryKey); |
|
|
|
|
|
|
|
|