本文整理汇总了C#中Dimension.AddDimensionLevel方法的典型用法代码示例。如果您正苦于以下问题:C# Dimension.AddDimensionLevel方法的具体用法?C# Dimension.AddDimensionLevel怎么用?C# Dimension.AddDimensionLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dimension
的用法示例。
在下文中一共展示了Dimension.AddDimensionLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDimensionsOf
public List<Dimension> GetDimensionsOf(string tablename)
{
// the tempTable is used to store the Database-results
DataTable tempTable = new DataTable();
DataTable tempTable2 = new DataTable();
// this list will be filled and returned
List<Dimension> dimensions = new List<Dimension>();
try
{
Open();
// see http://swp.offis.uni-oldenburg.de:8082/display/MPMDoku/Metadaten-Repository for sql-explanation
MySqlCommand getMetaDataSQL = new MySqlCommand(
"SELECT constraint_name as FromConstraint, table_name as FromTable, column_name as FromColumn, constraint_name as ToConstraint, " +
"referenced_table_name as ToTable, referenced_column_name as ToColumn " +
"FROM information_schema.key_column_usage " +
"WHERE constraint_schema = '" + DBWorker.getParams().Database + "' AND constraint_name != 'PRIMARY' AND table_name = '" + tablename + "' AND referenced_table_name != 'CASE';", Connection);
MySqlDataAdapter metaDataAdapter = new MySqlDataAdapter(getMetaDataSQL);
// Fill the temporally used Table
metaDataAdapter.Fill(tempTable);
// every Database-row is a dimension
foreach (DataRow row in tempTable.Rows)
{
// create a dimension-object (see MetaWorker.Dimension)
Dimension d = new Dimension(row["FromColumn"].ToString(), row["FromConstraint"].ToString(),
row["FromTable"].ToString(), row["FromColumn"].ToString(),
row["ToConstraint"].ToString(), row["ToTable"].ToString(), row["ToColumn"].ToString());
// Now get the Data than can be filtered later:
MySqlCommand getContentSQL = new MySqlCommand("SELECT * FROM `" + row["ToTable"].ToString() + "` LIMIT 100", Connection);
/*
* This SQL-Command seems pretty unsafe, why so? Well, Oracle lets you use parameters for the WHERE-part of the query,
* however you can't do the same thing for the FROM-part. God knows why.
*/
MySqlDataAdapter contentAdapter = new MySqlDataAdapter(getContentSQL);
// Fill the temporally used Table
contentAdapter.Fill(tempTable2);
// create DimensionContent-Objects and add them to the current dimension
foreach (DataRow row2 in tempTable2.Rows)
{
string desc = "";
if (row2.ItemArray.Count() > 2)
desc = row2[2].ToString();
d.DimensionContentsList.Add(new DimensionContent(row2[0].ToString(), row2[1].ToString(), desc));
}
// save the DimensionColumnNames for generated DB-querys
d.DimensionColumnNames = new DimensionColumnNames(tempTable2.Columns[0].ColumnName,
tempTable2.Columns[1].ColumnName, tempTable2.Columns[2].ColumnName);
tempTable2.Reset();
// now recursively find all sub-ListOfDimensions of this Table and add them to the current dimension
d.AddDimensionLevel(GetDimensionsOf(row["ToTable"].ToString()));
// add the current dimension to the list that will be returned eventually
dimensions.Add(d);
}
return dimensions;
}
finally
{
Close();
}
}