internal static SortedDictionary <string, ADOTabularMeasure> VisitMeasures(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", string.Format("{0}", 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); }
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 SortedDictionary <string, ADOTabularMeasure> Visit(ADOTabularMeasureCollection measures) { //RRomano: Better way to reuse this method in the two visitors? Create an abstract class of a visitor so that code can be shared (csdl doesnt seem to have the DAX expression) var ret = VisitMeasures(measures, this._conn); return(ret); }
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)); }
public SortedDictionary <string, ADOTabularMeasure> Visit(ADOTabularMeasureCollection measures) { if (measures == null) { throw new ArgumentNullException(nameof(measures)); } //RRomano: Better way to reuse this method in the two visitors? // Create an abstract class of a visitor so that code can be shared // (csdl doesnt seem to have the DAX expression) var ret = MetaDataVisitorADOMD.VisitMeasures(measures, this._conn); return(ret); }
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); }