ADO.NET provider for OData / Schema Details
In This Topic
    Schema Details
    In This Topic

    The ADO.NET provider for OData supports schema discovery using ADO.NET classes or SQL statements to the system tables. The ADO.NET classes enable access to schema information of database, connection property and columns returned.

    GetSchema method of C1ODataConnection class is used to retrieve schema of the Database and DataTables. 

    In the below code example GetSchema method is called which returns Tables in the Database. In the second call, the method returns the columns in a specific data table.

    using (C1ODataConnection connection = new C1ODataConnection($@"Url={ODataSampleUrl}"))
        //Get list of tables
        DataTable databaseTables = connection.GetSchema("Tables");
        Console.WriteLine("List of Tables in database:");
        foreach (DataRow row in databaseTables.Rows)
           //Display Tablename
        //Get column names in a table
        DataTable datatableColumns = connection.GetSchema("Columns", new string[] { "Products" });
        Console.WriteLine("\n Products Table columns:");
        foreach (DataRow column in datatableColumns.Rows)
           //Display column properties                  
           Console.Write("\t" + column["DataType"]);
           Console.Write("\t" + column["AllowDbNULL"] + "\n");