コード例 #1
0
 /// <summary>
 /// 获取数据库中所有存储过程
 /// </summary>
 /// <returns></returns>
 public Task <IEnumerable <Procedure> > GetProcedures()
 {
     return(Task.Factory.StartNew(() =>
     {
         using (var dbConnection = CreateDbConnection())
         {
             var sql = MySqlSQL.MySqlQueryProcedures(dbConnection.Database);
             return dbConnection.ExecuteModels <Procedure>(sql);
         }
     }));
 }
コード例 #2
0
 /// <summary>
 /// 获取表中的所有列
 /// </summary>
 /// <param name="tableName"></param>
 /// <returns></returns>
 public Task <IEnumerable <Column> > GetColumns(string tableName)
 {
     return(Task.Factory.StartNew((_tableName) =>
     {
         using (var dbConnection = CreateDbConnection())
         {
             var sql = MySqlSQL.MySqlQueryTableColumns(dbConnection.Database, (string)_tableName);
             return dbConnection.ExecuteModels <Column>(sql);
         }
     }, tableName));
 }
コード例 #3
0
 /// <summary>
 /// 获取数据库中所有外键关系
 /// </summary>
 /// <returns></returns>
 public Task <IEnumerable <ForeignKey> > GetForeignKeys()
 {
     return(Task.Factory.StartNew(() =>
     {
         using (var dbConnection = CreateDbConnection())
         {
             var sql = MySqlSQL.MySqlQueryForeignKeys(dbConnection.Database);
             return dbConnection.ExecuteModels <ForeignKey>(sql);
         }
     }));
 }
コード例 #4
0
        /// <summary>
        /// 获取存储过程参数列表
        /// </summary>
        /// <param name="procedureName"></param>
        /// <returns></returns>
        public Task <IEnumerable <ProcedureColumn> > GetProcedureColumns(string procedureName)
        {
            return(Task.Factory.StartNew((_procedureName) =>
            {
                var name = (string)_procedureName;

                using (var dbConnection = CreateDbConnection())
                {
                    var sql = MySqlSQL.MySqlQueryProcedureColumns(name);
                    return dbConnection.ExecuteModels <ProcedureColumn>(sql);
                }
            }, procedureName));
        }
コード例 #5
0
 /// <summary>
 /// 获取视图的脚本
 /// </summary>
 /// <param name="viewName"></param>
 /// <returns></returns>
 public Task <string> GetViewScript(string viewName)
 {
     return(Task.Factory.StartNew((_viewName) =>
     {
         var name = (string)_viewName;
         using (var dbConnection = CreateDbConnection())
         {
             var sql = MySqlSQL.MySqlQueryViewScript(name);
             var ret = dbConnection.ExecuteScalar(sql);
             if (ret == null)
             {
                 return string.Empty;
             }
             return (string)ret;
         }
     }, viewName));
 }
コード例 #6
0
 /// <summary>
 /// 获取存储过程的脚本
 /// </summary>
 /// <param name="procedureName"></param>
 /// <returns></returns>
 public Task <string> GetProcedureScript(string procedureName)
 {
     return(Task.Factory.StartNew((_procedureName) =>
     {
         var name = (string)_procedureName;
         using (var dbConnection = CreateDbConnection())
         {
             var sql = MySqlSQL.MySqlQueryProcedureScript(name);
             var dataTable = dbConnection.ExecuteDataTable(sql);
             if (dataTable.Rows.Count == 0)
             {
                 throw new Exception($"No procedure named '{procedureName}'");
             }
             var script = dataTable.Rows[0]["Create Procedure"];
             return (string)script;
         }
     }, procedureName));
 }