Browse Source

Update CodeFirst

pull/14/head
sunkaixuan 3 years ago
parent
commit
c2c224c4af
  1. 15
      Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs

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

@ -145,7 +145,12 @@ namespace SqlSugar
/// <returns>the text contents of this XML element node</returns> /// <returns>the text contents of this XML element node</returns>
public string GetXElementNodeValue(Type entityType, string nodeAttributeName) public string GetXElementNodeValue(Type entityType, string nodeAttributeName)
{ {
FileInfo file = new FileInfo(entityType.Assembly.Location); var path = entityType.Assembly.Location;
if (string.IsNullOrEmpty(path))
{
return null;
}
FileInfo file = new FileInfo(path);
string xmlPath = entityType.Assembly.Location.Replace(file.Extension, ".xml"); string xmlPath = entityType.Assembly.Location.Replace(file.Extension, ".xml");
if (!File.Exists(xmlPath)) if (!File.Exists(xmlPath))
{ {
@ -170,6 +175,10 @@ namespace SqlSugar
/// <returns>the code annotation for the database table</returns> /// <returns>the code annotation for the database table</returns>
public string GetTableAnnotation(Type entityType) public string GetTableAnnotation(Type entityType)
{ {
if (entityType.IsClass() == false)
{
return null;
}
var result= GetXElementNodeValue(entityType, $"T:{entityType.FullName}"); var result= GetXElementNodeValue(entityType, $"T:{entityType.FullName}");
if (string.IsNullOrEmpty(result)) if (string.IsNullOrEmpty(result))
{ {
@ -188,6 +197,10 @@ 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)
{
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))
{ {

Loading…
Cancel
Save