Querying with the DataAdapter
The CData ADO.NET Provider for Azure Active Directory implements two ADO.NET interfaces you can use to retrieve data from Azure Active Directory: AzureADDataAdapter and AzureADDataReader objects. Whereas AzureADDataAdapter objects retrieve a single result set of all the data that matches a query, AzureADDataReader objects fetch data in subset increments as needed.
Using the AzureADDataAdapter
Use the adapter's Fill method to retrieve data from the data source. An empty DataTable instance is passed as an argument to the Fill method. When the method returns, the DataTable instance is populated with the queried data. Note that the AzureADDataAdapter is slower than the AzureADDataReader because the Fill method needs to retrieve all data from the data source before returning.
The following example selects the Id and displayName columns of the DirectoryRoles table:
C#
string connectionString = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;"; using (AzureADConnection connection = new AzureADConnection(connectionString)) { AzureADDataAdapter dataAdapter = new AzureADDataAdapter( "SELECT Id, displayName FROM DirectoryRoles", connection); DataTable table = new DataTable(); dataAdapter.Fill(table); Console.WriteLine("Contents of DirectoryRoles."); foreach (DataRow row in table.Rows) { Console.WriteLine("{0}: {1}", row["Id"], row["displayName"]); } }
VB.NET
Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;" Using connection As New AzureADConnection(connectionString) Dim dataAdapter As New AzureADDataAdapter("SELECT Id, displayName FROM DirectoryRoles", connection) Dim table As New DataTable() dataAdapter.Fill(table) Console.WriteLine("Contents of DirectoryRoles.") For Each row As DataRow In table.Rows Console.WriteLine("{0}: {1}", row("Id"), row("displayName")) Next End Using