Browse Source

Add db.DbMain.GetProcList

pull/31/head
sunkaixuan 2 years ago
parent
commit
cdebd89918
  1. 4
      Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs
  2. 1
      Src/Asp.Net/SqlSugar/Interface/IDbMaintenance.cs
  3. 5
      Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs
  4. 5
      Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs
  5. 5
      Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs
  6. 5
      Src/Asp.Net/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs

4
Src/Asp.Net/SqlSugar/Abstract/DbMaintenanceProvider/Methods.cs

@ -10,6 +10,10 @@ namespace SqlSugar
public abstract partial class DbMaintenanceProvider : IDbMaintenance
{
#region DML
public virtual List<string> GetProcList(string dbName)
{
return new List<string>();
}
public virtual List<string> GetDataBaseList(SqlSugarClient db)
{
return db.Ado.SqlQuery<string>(this.GetDataBaseSql);

1
Src/Asp.Net/SqlSugar/Interface/IDbMaintenance.cs

@ -16,6 +16,7 @@ namespace SqlSugar
List<DbColumnInfo> GetColumnInfosByTableName(string tableName,bool isCache=true);
List<string> GetIsIdentities(string tableName);
List<string> GetPrimaries(string tableName);
List<string> GetProcList(string dbName);
#endregion
#region Check

5
Src/Asp.Net/SqlSugar/Realization/MySql/DbMaintenance/MySqlDbMaintenance.cs

@ -282,6 +282,11 @@ namespace SqlSugar
#endregion
#region Methods
public override List<string> GetProcList(string dbName)
{
var sql = $"SELECT ROUTINE_NAME FROM information_schema.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_SCHEMA = '{dbName}'";
return this.Context.Ado.SqlQuery<string>(sql);
}
public override bool IsAnyTable(string tableName, bool isCache = true)
{
try

5
Src/Asp.Net/SqlSugar/Realization/Oracle/DbMaintenance/OracleDbMaintenance.cs

@ -272,6 +272,11 @@ namespace SqlSugar
#endregion
#region Methods
public override List<string> GetProcList(string dbName)
{
var sql = $"SELECT OBJECT_NAME FROM ALL_OBJECTS WHERE OBJECT_TYPE = 'PROCEDURE' AND OWNER = '{dbName.ToUpper()}'";
return this.Context.Ado.SqlQuery<string>(sql);
}
public override bool AddColumn(string tableName, DbColumnInfo columnInfo)
{
if (columnInfo.DataType == "varchar"&& columnInfo.Length ==0)

5
Src/Asp.Net/SqlSugar/Realization/PostgreSQL/DbMaintenance/PostgreSQLDbMaintenance.cs

@ -249,6 +249,11 @@ namespace SqlSugar
#endregion
#region Methods
public override List<string> GetProcList(string dbName)
{
var sql = $"SELECT proname FROM pg_proc p JOIN pg_namespace n ON p.pronamespace = n.oid WHERE n.nspname = '{dbName}'";
return this.Context.Ado.SqlQuery<string>(sql);
}
public override bool AddDefaultValue(string tableName, string columnName, string defaultValue)
{
return base.AddDefaultValue(this.SqlBuilder.GetTranslationTableName(tableName), this.SqlBuilder.GetTranslationTableName(columnName), defaultValue);

5
Src/Asp.Net/SqlSugar/Realization/SqlServer/DbMaintenance/SqlServerDbMaintenance.cs

@ -321,6 +321,11 @@ namespace SqlSugar
#endregion
#region Methods
public override List<string> GetProcList(string dbName)
{
var sql = $"SELECT name FROM {dbName}.sys.procedures";
return this.Context.Ado.SqlQuery<string>(sql);
}
public override bool UpdateColumn(string tableName, DbColumnInfo column)
{
if (column.DataType != null && this.Context.CurrentConnectionConfig?.MoreSettings?.SqlServerCodeFirstNvarchar == true)

Loading…
Cancel
Save