Collections
The collections can be broadly grouped into two types: collections that are common to all data providers, and collections specific to a particular provider.
Common
The following collections are common to all data providers:
- MetaDataCollections
- DataSourceInformation
- DataTypes
- Restrictions
- ReservedWords
Provider-specific
The following are the collections currently provided by MariaDB Connector/Net, in addition to the common collections above:
- Databases
- Tables
- Columns
- Users
- Foreign Keys
- IndexColumns
- Indexes
- Foreign Key Columns
- UDF
- Views
- ViewColumns
- Procedure Parameters
- Procedures
- Triggers
Example Code
A list of available collections can be obtained using the following code:
using System; using System.Data; using System.Text; using MySql.Data; using MySql.Data.MySqlClient; namespace ConsoleApplication2 { class Program { private static void DisplayData(System.Data.DataTable table) { foreach (System.Data.DataRow row in table.Rows) { foreach (System.Data.DataColumn col in table.Columns) { Console.WriteLine('{0} = {1}', col.ColumnName, row[col]); } Console.WriteLine('============================'); } } static void Main(string[] args) { string connStr = 'server=localhost;user=root;database=world;port=3306;password=******;'; MySqlConnection conn = new MySqlConnection(connStr); try { Console.WriteLine('Connecting to MariaDB...'); conn.Open(); DataTable table = conn.GetSchema('MetaDataCollections'); //DataTable table = conn.GetSchema('UDF'); DisplayData(table); conn.Close(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Console.WriteLine('Done.'); } } }
Further information on the GetSchema()
method and schema collections can be found in the Microsoft .NET documentation.