DataConnector
ADO.NET provider for Dynamics 365 Sales / Schema Details
In This Topic
    Schema Details
    In This Topic

    The ADO.NET provider for Dynamics 365 Sales 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 C1D365SConnection 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 (C1D365SConnection connection = new C1D365SConnection(connstr))
    {
      connection.Open();
      //Get list of tables
      DataTable databaseTables = connection.GetSchema("Tables");
      Console.WriteLine("List of Tables in database: \n");
      foreach (DataRow row in databaseTables.Rows)
      {
        //Display table names
        Console.WriteLine(row["TableName"]);//Table Name
      }
      //Get column names in a table
      DataTable datatableColumns = connection.GetSchema("Columns", new string[]   { "Accounts" });
      Console.WriteLine("\n Accounts table Columns:");
      foreach (DataRow column in datatableColumns.Rows)
      {
         //Display column properties                    
         Console.Write(column["ColumnName"]);
         Console.Write("\t" + column["DataType"]);
         Console.Write("\t" + column["AllowDbNULL"] + "\n");
      }
    }