修复codefirst从xml读取属性注释时没有读取父属性注释,导致数据库表有的字段有注释有的没有注释。

This commit is contained in:
YHS 2023-04-04 10:19:07 +08:00
parent 2f284a20c3
commit 0d1aa38d92
2 changed files with 8 additions and 6 deletions

View File

@ -234,14 +234,15 @@ namespace SqlSugar
/// <returns>the code annotation for the field</returns> /// <returns>the code annotation for the field</returns>
public string GetPropertyAnnotation(Type entityType, string dbColumnName) public string GetPropertyAnnotation(Type entityType, string dbColumnName)
{ {
if (entityType.IsClass() == false) if (entityType.IsClass() == false || entityType == typeof(object))
{ {
return null; return null;
} }
var result = GetXElementNodeValue(entityType, $"P:{entityType.FullName}.{dbColumnName}"); var result = GetXElementNodeValue(entityType, $"P:{entityType.FullName}.{dbColumnName}");
if (string.IsNullOrEmpty(result)) if (string.IsNullOrEmpty(result))
{ {
return null; return GetPropertyAnnotation(entityType.BaseType, dbColumnName);
} }
else else
{ {

View File

@ -234,14 +234,15 @@ namespace SqlSugar
/// <returns>the code annotation for the field</returns> /// <returns>the code annotation for the field</returns>
public string GetPropertyAnnotation(Type entityType, string dbColumnName) public string GetPropertyAnnotation(Type entityType, string dbColumnName)
{ {
if (entityType.IsClass() == false) if (entityType.IsClass() == false || entityType == typeof(object))
{ {
return null; return null;
} }
var result = GetXElementNodeValue(entityType, $"P:{entityType.FullName}.{dbColumnName}"); var result = GetXElementNodeValue(entityType, $"P:{entityType.FullName}.{dbColumnName}");
if (string.IsNullOrEmpty(result)) if (string.IsNullOrEmpty(result))
{ {
return null; return GetPropertyAnnotation(entityType.BaseType, dbColumnName);
} }
else else
{ {