Пример #1
0
 public ADOTabularKeywordCollection(IADOTabularConnection adoTabularConnection)
 {
     if (adoTabularConnection == null)
     {
         throw new ArgumentNullException(nameof(adoTabularConnection));
     }
     _connection = adoTabularConnection;
     _connection.Visitor.Visit(this);
 }
Пример #2
0
 public ADOTabularColumnCollection(IADOTabularConnection adoTabConn, ADOTabularTable table)
 {
     Table       = table;
     _adoTabConn = adoTabConn;
     if (_cols == null)
     {
         _cols = _adoTabConn.Visitor.Visit(this);
     }
 }
Пример #3
0
 public ADOTabularDatabase(IADOTabularConnection adoTabConn, string databaseName, string databaseId, DateTime lastUpdate, string compatLevel, string roles)
 {
     Connection         = adoTabConn;
     Name               = databaseName;
     Id                 = databaseId;
     LastUpdate         = lastUpdate;
     CompatibilityLevel = compatLevel;
     Roles              = roles;
 }
        public ADOTabularColumnCollection(IADOTabularConnection adoTabConn, ADOTabularTable table)
        {
            Contract.Requires(adoTabConn != null, "The adoTabConn parameter must not be null");

            Table       = table;
            _adoTabConn = adoTabConn;
            _colsByRef  = new SortedDictionary <string, ADOTabularColumn>();
            _cols ??= _adoTabConn.Visitor.Visit(this);
        }
 public ADOTabularMeasureCollection(IADOTabularConnection adoTabConn, ADOTabularTable table)
 {
     _table      = table;
     _adoTabConn = adoTabConn;
     if (_measures == null)
     {
         _measures = _adoTabConn.Visitor.Visit(this);
     }
 }
Пример #6
0
        public ADOTabularMeasureCollection(IADOTabularConnection adoTabConn, ADOTabularTable table)
        {
            Table       = table;
            _adoTabConn = adoTabConn ?? throw new ArgumentNullException(nameof(adoTabConn));

            if (_measures == null)
            {
                _measures = _adoTabConn.Visitor.Visit(this);
            }
        }
Пример #7
0
 public ADOTabularModel(IADOTabularConnection adoTabConn, string name, string caption, string description, string baseModelName)
 {
     _adoTabConn   = adoTabConn;
     Name          = name;
     Caption       = caption;
     Description   = description;
     BaseModelName = baseModelName;
     Roles         = new Dictionary <string, ADOTabularColumn>();
     Relationships = new List <ADOTabularRelationship>();
 }
 public ADOTabularColumnCollection(IADOTabularConnection adoTabConn, ADOTabularTable table)
 {
     Table       = table;
     _adoTabConn = adoTabConn;
     if (_cols == null)
     {
         _cols = _adoTabConn.Visitor.Visit(this);
     }
     _colsByRef = new SortedDictionary <string, ADOTabularColumn>();
 }
Пример #9
0
 public ADOTabularModel(IADOTabularConnection adoTabConn, DataRow dr)
 {
     _adoTabConn   = adoTabConn;
     Name          = dr["CUBE_NAME"].ToString();
     Caption       = dr["CUBE_CAPTION"].ToString();
     Description   = dr["DESCRIPTION"].ToString();
     BaseModelName = dr["BASE_CUBE_NAME"].ToString();
     Roles         = new Dictionary <string, ADOTabularColumn>();
     Relationships = new List <ADOTabularRelationship>();
 }
        public void MyTestInitialize()
        {
            var mockConn         = new Mock <IADOTabularConnection>();
            var columnCollection = new Dictionary <string, ADOTabularColumn>();

            mockConn.SetupGet(x => x.Columns).Returns(columnCollection);
            mockConn.Setup(x => x.GetSchemaDataSet("DISCOVER_KEYWORDS", null, false)).Returns(keywordDataSet);
            mockConn.Setup(x => x.GetSchemaDataSet("MDSCHEMA_FUNCTIONS", null, false)).Returns(functionDataSet);
            mockConn.Setup(x => x.GetSchemaDataSet("MDSCHEMA_CUBES", It.IsAny <AdomdRestrictionCollection>())).Returns(cubesDataSet);
            mockConn.Setup(x => x.ShowHiddenObjects).Returns(true);
            var mockDb = new Mock <ADOTabularDatabase>(mockConn.Object, "Adventure Works", "Adventure Works", new DateTime(2017, 7, 20), "1400", "*");

            mockDatabase = mockDb.Object;
            mockConn.SetupGet(x => x.Database).Returns(mockDatabase);
            mockConn.Setup(x => x.GetSchemaDataSet(
                               "MDSCHEMA_MEASURES",
                               It.Is <AdomdRestrictionCollection>(res => IsResellerSalesMeasureGroup(res)),
                               false))
            .Returns(measureDataSet);
            mockConn.Setup(x => x.GetSchemaDataSet(
                               "MDSCHEMA_MEASURES",
                               It.Is <AdomdRestrictionCollection>(res => !IsResellerSalesMeasureGroup(res)),
                               false))
            .Returns(measureDataSetEmpty);
            mockConn.Setup(x => x.GetSchemaDataSet(
                               "MDSCHEMA_MEASURES",
                               It.Is <AdomdRestrictionCollection>(res => IsResellerSalesMeasureGroup(res))
                               ))
            .Returns(measureDataSet);
            mockConn.Setup(x => x.GetSchemaDataSet(
                               "MDSCHEMA_MEASURES",
                               It.Is <AdomdRestrictionCollection>(res => !IsResellerSalesMeasureGroup(res))
                               ))
            .Returns(measureDataSetEmpty);
            mockConn.Setup(x => x.GetSchemaDataSet(
                               "DISCOVER_CSDL_METADATA",
                               It.IsAny <AdomdRestrictionCollection>()
                               ))
            .Returns(csdlMetaDataRowset);
            mockConn.Setup(x => x.GetSchemaDataSet(
                               "MDSCHEMA_HIERARCHIES",
                               It.IsAny <AdomdRestrictionCollection>()
                               ))
            .Returns(emptyDataSet);
            mockConn.Setup(x => x.ServerVersion).Returns("15.0.0");
            mockConn.SetupGet(x => x.Visitor).Returns(new MetaDataVisitorCSDL(mockConn.Object));

            mockConn.SetupGet(x => x.Keywords).Returns(new ADOTabularKeywordCollection(mockConn.Object));
            mockConn.SetupGet(x => x.AllFunctions).Returns(new List <string>());

            connection = mockConn.Object;
        }
Пример #11
0
 /* public ADOTabularTable(ADOTabularConnection adoTabConn, DataRow dr, ADOTabularModel model)
  * {
  *   Caption = dr["DIMENSION_NAME"].ToString();
  *   IsVisible = bool.Parse(dr["DIMENSION_IS_VISIBLE"].ToString());
  *   Description = dr["DESCRIPTION"].ToString();
  *   _adoTabConn = adoTabConn;
  *   _model = model;
  * }
  */
 public ADOTabularTable(IADOTabularConnection adoTabConn, string internalReference, string name, string caption, string description, bool isVisible, bool _private, bool showAsVariationsOnly)
 {
     _adoTabConn       = adoTabConn;
     InternalReference = internalReference;
     Name                 = name ?? internalReference;
     Caption              = caption ?? name ?? internalReference;
     DaxName              = GetDaxName();
     Description          = description;
     IsVisible            = isVisible;
     Relationships        = new List <ADOTabularRelationship>();
     FolderItems          = new List <IADOTabularObjectReference>();
     Private              = _private;
     ShowAsVariationsOnly = showAsVariationsOnly;
 }
Пример #12
0
        //public ADOTabularModel(IADOTabularConnection adoTabConn, DataRow dr)
        //{
        //    _adoTabConn = adoTabConn;
        //    Name = dr["CUBE_NAME"].ToString();
        //    Caption = dr["CUBE_CAPTION"].ToString();
        //    Description = dr["DESCRIPTION"].ToString();
        //    BaseModelName = dr["BASE_CUBE_NAME"].ToString();
        //    Roles = new Dictionary<string, ADOTabularColumn>();
        //    Relationships = new List<ADOTabularRelationship>();
        //}

        public ADOTabularModel(IADOTabularConnection adoTabConn, ADOTabularDatabase database, string name, string caption, string description, string baseModelName)
        {
            _adoTabConn   = adoTabConn;
            Database      = database;
            Name          = name;
            Caption       = caption;
            Description   = description;
            BaseModelName = baseModelName;
            Roles         = new Dictionary <string, ADOTabularColumn>();
            Relationships = new List <ADOTabularRelationship>();
            TOMModel      = new Model()
            {
                Name = name
            };
            MeasureExpressions = new Dictionary <string, string>();
        }
Пример #13
0
 public MetaDataVisitorCSDL(IADOTabularConnection conn)
 {
     _conn = conn;
 }
Пример #14
0
        private static SortedDictionary <string, ADOTabularMeasure> GetTmSchemaMeasures(ADOTabularMeasureCollection measures, IADOTabularConnection conn)
        {
            var resCollTables = new AdomdRestrictionCollection
            {
                { "Name", measures.Table.Caption },
            };

            // need to look up the TableID in TMSCHEMA_TABLES
            DataTable dtTables = conn.GetSchemaDataSet("TMSCHEMA_TABLES", resCollTables).Tables[0];
            var       tableId  = dtTables.Rows[0].Field <System.UInt64>("ID");

            var ret             = new SortedDictionary <string, ADOTabularMeasure>();
            var resCollMeasures = new AdomdRestrictionCollection
            {
                { "DatabaseName", conn.Database.Name },
                { "TableID", tableId },
            };

            if (!conn.ShowHiddenObjects)
            {
                resCollMeasures.Add(new AdomdRestriction("IsHidden", false));
            }

            // then get all the measures for the current table
            DataTable dtMeasures = conn.GetSchemaDataSet("TMSCHEMA_MEASURES", resCollMeasures).Tables[0];

            foreach (DataRow dr in dtMeasures.Rows)
            {
                ret.Add(dr["Name"].ToString()
                        , new ADOTabularMeasure(measures.Table
                                                , dr["Name"].ToString()
                                                , dr["Name"].ToString()
                                                , dr["Name"].ToString() // TODO - TMSCHEMA_MEASURES does not have a caption property
                                                , dr["Description"].ToString()
                                                , !bool.Parse(dr["IsHidden"].ToString())
                                                , dr["Expression"].ToString()
                                                )
                        );
            }

            return(ret);
        }
Пример #15
0
        private static SortedDictionary <string, ADOTabularMeasure> GetMdSchemaMeasures(ADOTabularMeasureCollection measures, IADOTabularConnection conn)
        {
            var ret = new SortedDictionary <string, ADOTabularMeasure>();

            var resCollMeasures = new AdomdRestrictionCollection
            {
                { "CATALOG_NAME", conn.Database.Name },
                { "CUBE_NAME", conn.Database.Models.BaseModel.Name },
                { "MEASUREGROUP_NAME", measures.Table.Caption },
                {
                    "MEASURE_VISIBILITY",
                    conn.ShowHiddenObjects
                            ? (int)(MdschemaVisibility.Visible | MdschemaVisibility.NonVisible)
                            : (int)(MdschemaVisibility.Visible)
                }
            };

            DataTable dtMeasures = conn.GetSchemaDataSet("MDSCHEMA_MEASURES", resCollMeasures).Tables[0];

            foreach (DataRow dr in dtMeasures.Rows)
            {
                ret.Add(dr["MEASURE_NAME"].ToString()
                        , new ADOTabularMeasure(measures.Table
                                                , dr["MEASURE_NAME"].ToString()
                                                , dr["MEASURE_NAME"].ToString()
                                                , dr["MEASURE_CAPTION"].ToString()
                                                , dr["DESCRIPTION"].ToString()
                                                , bool.Parse(dr["MEASURE_IS_VISIBLE"].ToString())
                                                , dr["EXPRESSION"].ToString()
                                                )
                        );
            }

            return(ret);
        }
Пример #16
0
 internal static SortedDictionary <string, ADOTabularMeasure> VisitMeasures(ADOTabularMeasureCollection measures, IADOTabularConnection conn)
 {
     if (conn.DynamicManagementViews.Any(dmv => dmv.Name == "TMSCHEMA_MEASURES") && conn.IsAdminConnection)
     {
         return(GetTmSchemaMeasures(measures, conn));
     }
     return(GetMdSchemaMeasures(measures, conn));
 }
 public ADOTabularKeywordCollection(IADOTabularConnection adoTabularConnection)
 {
     // TODO: Complete member initialization
     _connection = adoTabularConnection;
     _connection.Visitor.Visit(this);
 }
 public ADOTabularDynamicManagementViewCollection(IADOTabularConnection adoTabConn)
 {
     _adoTabConn = adoTabConn;
 }
Пример #19
0
 public ADOTabularTableCollection(IADOTabularConnection adoTabConn, ADOTabularModel model)
 {
     _adoTabConn = adoTabConn;
     _model      = model;
 }
Пример #20
0
 internal static SortedDictionary <string, ADOTabularMeasure> VisitMeasures(ADOTabularMeasureCollection measures, IADOTabularConnection conn)
 {
     // need to check if the DMV collection has the TMSCHEMA_MEASURES view,
     // and if this is a connection with admin rights
     // and if it is not a PowerPivot model (as they seem to throw an error about the model needing to be in the "new" tabular mode)
     if (conn.DynamicManagementViews.Any(dmv => dmv.Name == "TMSCHEMA_MEASURES") && conn.IsAdminConnection && !conn.IsPowerPivot)
     {
         return(GetTmSchemaMeasures(measures, conn));
     }
     return(GetMdSchemaMeasures(measures, conn));
 }
Пример #21
0
 public ADOTabularModelCollection(IADOTabularConnection adoTabConn, ADOTabularDatabase database)
 {
     _adoTabConn = adoTabConn;
     Database    = database;
     //_models = _adoTabConn.Visitor.Visit(this);
 }