mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-01-28 11:11:32 +08:00
Add IsAnyTable<T>
This commit is contained in:
@@ -133,6 +133,28 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Check
|
#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)
|
public virtual bool IsAnyTable(string tableName, bool isCache = true)
|
||||||
{
|
{
|
||||||
Check.Exception(string.IsNullOrEmpty(tableName), "IsAnyTable tableName is not null");
|
Check.Exception(string.IsNullOrEmpty(tableName), "IsAnyTable tableName is not null");
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Check
|
#region Check
|
||||||
|
bool IsAnyTable<T>();
|
||||||
bool IsAnyTable(string tableName, bool isCache = true);
|
bool IsAnyTable(string tableName, bool isCache = true);
|
||||||
bool IsAnyColumn(string tableName, string column, bool isCache = true);
|
bool IsAnyColumn(string tableName, string column, bool isCache = true);
|
||||||
bool IsPrimaryKey(string tableName, string column);
|
bool IsPrimaryKey(string tableName, string column);
|
||||||
|
|||||||
Reference in New Issue
Block a user