DataConnector
スキーマの詳細
ADO.NET provider for JSON > スキーマの詳細

The ADO.NET provider for JSON 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 and the GetSchema method can be used to retrieve schema of the Database and DataTables. 

The following code shows how the GetSchema method is called which returns Tables in the Database. In the second call, the method returns the columns in a specific data table.

C#
コードのコピー
static void Read_Schema()
{
    static string documentConnectionString = $"Data Model=Document;Uri='json_bookstore.json';Json Path='$.bookstore.books'";
        
    Console.WriteLine("Query all Accounts...");
    using (var con = new C1JsonConnection(documentConnectionString))
    {
        con.Open();

        //テーブルのリストを取得します。
        DataTable databaseTables = con.GetSchema("Tables");
        Console.WriteLine("List of Tables in database:");
        foreach (DataRow row in databaseTables.Rows)
        {
            //テーブル名を表示します。
            Console.WriteLine(row["TableName"]);
        }
        //テーブル内の列名を取得します。

        DataTable datatableColumns = con.GetSchema("Columns", new string[] { "books" });
        Console.WriteLine("\n Books Table columns:");
        foreach (DataRow column in datatableColumns.Rows)
        {
            //列のプロパティを表示します。                
            Console.Write(column["ColumnName"]);
            Console.Write("\t" + column["DataType"]);
        }
    }
}
static void ShowDataTable(DataTable table, int length = 25)
{
    foreach (DataColumn col in table.Columns)
    {
        Console.Write("{0,-" + length + "}", col.ColumnName);
    }
    Console.WriteLine();

    foreach (DataRow row in table.Rows)
    {
        foreach (DataColumn col in table.Columns)
        {
            if (col.DataType.Equals(typeof(DateTime)))
                Console.Write("{0,-" + length + ":d}", row[col]);
            else if (col.DataType.Equals(typeof(decimal)))
                Console.Write("{0,-" + length + ":C}", row[col]);
            else
                Console.Write("{0,-" + length + "}", row[col]);
        }
        Console.WriteLine();
    }
}

Similar to the GetSchema method, you can also use GetSchemaTable method of the C1DataReader class. The GetSchemaTable method returns a DataTable that defines the column metadata.