当前位置: 首页>>代码示例>>C#>>正文


C# Dimension.AddDimensionLevel方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:ThomasMeents,项目名称:ProcessCubeExplorer,代码行数:70,代码来源:MySQLConnect.cs


注:本文中的Dimension.AddDimensionLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。