Browse Source

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

pull/31/head
YHS 2 years ago
parent
commit
0d1aa38d92
  1. 7
      Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs
  2. 7
      Src/Asp.NetCore2/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs

7
Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs

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

7
Src/Asp.NetCore2/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs

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

Loading…
Cancel
Save