public void DataTableTest() { var dataTable = new DataTable(); var connection = UnitTestHelpers.GetCapellaDataTestConnection(); using (connection) { connection.Open(); const string query = @"SELECT [Measures].[Response Computation] on 0, [Organization].[Organization].&[407] on 1 FROM Report WHERE ([Computation].[Computation].&[Mean], [Questionnaire].[Questionnaire Version - Questionnaire - Question Category - Question].[Question].&[SalesDemo]&[2]&[Q2] )"; using (var command = connection.CreateCommand()) { command.CommandText = query; command.Parameters.Add(new MdxParameter("~[Measures].[Response Computation]", "Score")); command.Parameters.Add(new MdxParameter("~[Organization].[Organization].[Level 05]", "Store")); using (var dataAdapter = new MdxDataAdapter()) { dataAdapter.SelectCommand = command; dataAdapter.Fill(dataTable); } } // Verify data foreach (DataRow item in dataTable.Rows) { Assert.AreEqual("Chicago (IL)", item[0].ToString()); Assert.AreEqual(64.6481481481482, (double)item[1], .000000001); break; } } }
public void DataSetTestWithoutColumnMap() { var dataSet = new DataSet(); var connection = UnitTestHelpers.GetCapellaDataTestConnection(); using (connection) { connection.Open(); const string query = @"SELECT [Measures].[Response Computation] on 0, [Organization].[Organization].&[407] on 1 FROM Report WHERE ([Computation].[Computation].&[Mean], [Questionnaire].[Questionnaire Version - Questionnaire - Question Category - Question].[Question].&[SalesDemo]&[2]&[Q2] )"; using (var command = connection.CreateCommand()) { command.CommandText = query; var dataAdapter = new MdxDataAdapter { SelectCommand = command }; dataAdapter.Fill(dataSet); } // Verify there is a table Assert.AreEqual(1, dataSet.Tables.Count); // Verify data foreach (DataRow item in dataSet.Tables[0].Rows) { Assert.AreEqual("Chicago (IL)", item[0].ToString()); Assert.AreEqual(64.6481481481482, (double)item[1], .000000001); break; } } }