Exemplo n.º 1
0
        /// <summary>
        /// 获取数据库表的信息.
        /// </summary>
        /// <returns></returns>
        public List <TableInfoModel> GetTables()
        {
            List <TableInfoModel> Result = null;

            using (MySqlCommand Command = (MySqlCommand)DbEngine.DBA.CreateDbCommand())
            {
                Command.Connection  = (MySqlConnection)DbEngine.DBA.Connect();
                Command.CommandText = global::Wunion.DataAdapter.EntityGenerator.Properties.Resources.MySQLDbSchema;
                Command.CommandType = CommandType.Text;
                Command.Parameters.Add((MySqlParameter)(DbEngine.DBA.CreateParameter("dbName", GetDbName())));
                Command.Connection.Open();
                MySqlDataReader Rd = Command.ExecuteReader(CommandBehavior.CloseConnection);
                Result = new List <TableInfoModel>();
                int            i;
                TableInfoModel tableInfo;
                while (Rd.Read())
                {
                    tableInfo = new TableInfoModel();
                    for (i = 0; i < Rd.FieldCount; ++i)
                    {
                        tableInfo.SetValue(Rd.GetName(i), Rd.GetValue(i), true);
                    }
                    Result.Add(tableInfo);
                }
                Rd.Close();
            }
            return(Result);
        }
        /// <summary>
        /// 获取数据库表的信息.
        /// </summary>
        /// <returns></returns>
        public List <TableInfoModel> GetTables()
        {
            string commandText = global::Wunion.DataAdapter.EntityGenerator.Properties.Resources.SQLServerDbSchema;
            //command = command.Replace("{TABLE_NAME}", TableName);
            List <TableInfoModel> Result = null;

            using (SqlCommand Command = (SqlCommand)DbEngine.DBA.CreateDbCommand())
            {
                Command.Connection  = (SqlConnection)DbEngine.DBA.Connect();
                Command.CommandText = commandText;
                Command.CommandType = CommandType.Text;
                Command.Connection.Open();
                SqlDataReader Rd = Command.ExecuteReader(CommandBehavior.CloseConnection);

                Result = new List <TableInfoModel>();
                int            i;
                string         field;
                TableInfoModel tableInfo;
                while (Rd.Read())
                {
                    tableInfo = new TableInfoModel();
                    for (i = 0; i < Rd.FieldCount; ++i)
                    {
                        field = Rd.GetName(i);
                        tableInfo.SetValue(field, Rd.GetValue(i), true);
                    }
                    Result.Add(tableInfo);
                }
                Rd.Close();
            }
            return(Result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取数据库表的信息.
        /// </summary>
        /// <returns></returns>
        public List <TableInfoModel> GetTables()
        {
            string commandText           = global::Wunion.DataAdapter.EntityGenerator.Properties.Resources.PostgreSQLDbSchema;
            List <TableInfoModel> Result = null;

            using (NpgsqlCommand Command = (NpgsqlCommand)DbEngine.DBA.CreateDbCommand())
            {
                Command.Connection  = (NpgsqlConnection)DbEngine.DBA.Connect();
                Command.CommandText = commandText;
                Command.CommandType = CommandType.Text;
                Command.Connection.Open();
                NpgsqlDataReader Rd = Command.ExecuteReader(CommandBehavior.CloseConnection);

                Result = new List <TableInfoModel>();
                int            i;
                TableInfoModel tableInfo;
                while (Rd.Read())
                {
                    tableInfo = new TableInfoModel();
                    tableInfo.SetValue("tableName", Rd["tablename"], true);
                    tableInfo.SetValue("paramName", Rd["paramname"], true);
                    tableInfo.SetValue("allowNull", Rd["allownull"], true);
                    tableInfo.SetValue("dbType", Rd["dbtype"], true);
                    tableInfo.SetValue("isPrimary", Rd["isprimary"], true);
                    tableInfo.SetValue("isIdentity", Rd["isidentity"], true);
                    Result.Add(tableInfo);
                }
                Rd.Close();
            }
            return(Result);
        }