Add IsAnyTable<T>

This commit is contained in:
sunkaixuan
2025-04-26 15:59:54 +08:00
parent eb6a041b0f
commit 4adeb10cf2
2 changed files with 23 additions and 0 deletions

View File

@@ -133,6 +133,28 @@ namespace SqlSugar
#endregion
#region Check
public virtual bool IsAnyTable<T>()
{
if (typeof(T).GetCustomAttribute<SplitTableAttribute>() != null)
{
var tables = this.Context.SplitHelper(typeof(T)).GetTables();
var isAny = false;
foreach (var item in tables)
{
if (this.Context.DbMaintenance.IsAnyTable(item.TableName, false))
{
isAny = true;
break;
}
}
return isAny;
}
else
{
this.Context.InitMappingInfo<T>();
return this.IsAnyTable(this.Context.EntityMaintenance.GetEntityInfo<T>().DbTableName,false);
}
}
public virtual bool IsAnyTable(string tableName, bool isCache = true)
{
Check.Exception(string.IsNullOrEmpty(tableName), "IsAnyTable tableName is not null");

View File

@@ -27,6 +27,7 @@ namespace SqlSugar
#endregion
#region Check
bool IsAnyTable<T>();
bool IsAnyTable(string tableName, bool isCache = true);
bool IsAnyColumn(string tableName, string column, bool isCache = true);
bool IsPrimaryKey(string tableName, string column);