From c2c224c4aff36c15b27cb052a778b7e7cf598464 Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Tue, 8 Mar 2022 15:27:54 +0800
Subject: [PATCH] Update CodeFirst
---
.../EntityMaintenance/EntityMaintenance.cs | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs b/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs
index 96cf92b1d..8b98889f4 100644
--- a/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs
+++ b/Src/Asp.Net/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs
@@ -145,7 +145,12 @@ namespace SqlSugar
/// the text contents of this XML element node
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");
if (!File.Exists(xmlPath))
{
@@ -170,6 +175,10 @@ namespace SqlSugar
/// the code annotation for the database table
public string GetTableAnnotation(Type entityType)
{
+ if (entityType.IsClass() == false)
+ {
+ return null;
+ }
var result= GetXElementNodeValue(entityType, $"T:{entityType.FullName}");
if (string.IsNullOrEmpty(result))
{
@@ -188,6 +197,10 @@ namespace SqlSugar
/// the code annotation for the field
public string GetPropertyAnnotation(Type entityType, string dbColumnName)
{
+ if (entityType.IsClass() == false)
+ {
+ return null;
+ }
var result= GetXElementNodeValue(entityType, $"P:{entityType.FullName}.{dbColumnName}");
if (string.IsNullOrEmpty(result))
{