Querying with the DataAdapter
The CData ADO.NET Provider for Workday implements two ADO.NET interfaces you can use to retrieve data from Workday: WorkdayDataAdapter and WorkdayDataReader objects. Whereas WorkdayDataAdapter objects retrieve a single result set of all the data that matches a query, WorkdayDataReader objects fetch data in subset increments as needed.
Using the WorkdayDataAdapter
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 WorkdayDataAdapter is slower than the WorkdayDataReader because the Fill method needs to retrieve all data from the data source before returning.
The following example selects the Worker_Reference_WID and Legal_Name_Last_Name columns of the Workers table:
C#
string connectionString = "ConnectionType=SOAP;User=myuser;Password=mypassword;Tenant=mycompany;BaseURL=https://wd3-impl-services1.workday.com"; using (WorkdayConnection connection = new WorkdayConnection(connectionString)) { WorkdayDataAdapter dataAdapter = new WorkdayDataAdapter( "SELECT Worker_Reference_WID, Legal_Name_Last_Name FROM [CData].[Human_Resources].Workers", connection); DataTable table = new DataTable(); dataAdapter.Fill(table); Console.WriteLine("Contents of Workers."); foreach (DataRow row in table.Rows) { Console.WriteLine("{0}: {1}", row["Worker_Reference_WID"], row["Legal_Name_Last_Name"]); } }
VB.NET
Dim connectionString As String = "ConnectionType=SOAP;User=myuser;Password=mypassword;Tenant=mycompany;BaseURL=https://wd3-impl-services1.workday.com" Using connection As New WorkdayConnection(connectionString) Dim dataAdapter As New WorkdayDataAdapter("SELECT Worker_Reference_WID, Legal_Name_Last_Name FROM [CData].[Human_Resources].Workers", connection) Dim table As New DataTable() dataAdapter.Fill(table) Console.WriteLine("Contents of Workers.") For Each row As DataRow In table.Rows Console.WriteLine("{0}: {1}", row("Worker_Reference_WID"), row("Legal_Name_Last_Name")) Next End Using