/// <summary> /// Dump internal model structure /// </summary> static void SimpleDump() { Dax.Model.Model m = new Dax.Model.Model(); Dax.Model.Table tA = new Dax.Model.Table(m) { TableName = new Dax.Model.DaxName("A") }; Dax.Model.Table tB = new Dax.Model.Table(m) { TableName = new Dax.Model.DaxName("B") }; Dax.Model.Column ca1 = new Dax.Model.Column(tA) { ColumnName = new Dax.Model.DaxName("A_1") }; Dax.Model.Column ca2 = new Dax.Model.Column(tA) { ColumnName = new Dax.Model.DaxName("A_2") }; tA.Columns.Add(ca1); tA.Columns.Add(ca2); m.Tables.Add(tA); // Test serialization on JSON file var json = JsonConvert.SerializeObject(m, Formatting.Indented, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All }); System.IO.File.WriteAllText(@"C:\temp\model.json", json); }
private void AddTable(Tom.Table table) { var partitions = table.Partitions; Tom.PartitionSourceType tableType = (partitions?.Count > 0) ? (partitions[0].SourceType) : Tom.PartitionSourceType.None; bool isCalculatedTable = (tableType == Tom.PartitionSourceType.Calculated); bool isCalculationGroup = (tableType == Tom.PartitionSourceType.CalculationGroup); var partitionSource = (isCalculatedTable) ? partitions[0].Source as Tom.CalculatedPartitionSource : null; Dax.Model.Table daxTable = new Dax.Model.Table(DaxModel) { TableName = new Dax.Model.DaxName(table.Name), IsHidden = table.IsHidden, TableExpression = Dax.Model.DaxExpression.GetExpression(isCalculatedTable ? partitionSource.Expression : null), TableType = isCalculatedTable ? Table.TableSourceType.CalculatedTable.ToString() : (isCalculationGroup ? Table.TableSourceType.CalculationGroup.ToString() : null), Description = table.Description }; foreach (var column in table.Columns) { AddColumn(daxTable, column); } foreach (var measure in table.Measures) { AddMeasure(daxTable, measure); } foreach (var hierarchy in table.Hierarchies) { AddUserHierarchy(daxTable, hierarchy); } // Add calculation groups and calculation items if (table.CalculationGroup != null) { var calcGroup = new CalculationGroup(daxTable) { Precedence = table.CalculationGroup.Precedence }; foreach (var calcItem in table.CalculationGroup.CalculationItems) { AddCalculationItem(calcGroup, calcItem); } daxTable.CalculationGroup = calcGroup; // Set the first column of the table that is not a RowNumber as a calculation group attribute foreach (var column in daxTable.Columns) { if (!column.IsRowNumber) { column.IsCalculationGroupAttribute = true; break; } } } DaxModel.Tables.Add(daxTable); }
/// <summary> // Search a DAX Table or create one if it does not exist /// </summary> /// <param name="tableName">Name of the table to search</param> /// <returns></returns> private Table GetDaxTable(string tableName) { var daxTable = DaxModel.Tables.Where(t => t.TableName.Name.Equals(tableName)).FirstOrDefault(); if (daxTable == null) { daxTable = new Dax.Model.Table(DaxModel) { TableName = new Dax.Model.DaxName(tableName) }; DaxModel.Tables.Add(daxTable); } return(daxTable); }
private void AddRelationship(Tom.SingleColumnRelationship relationship) { Dax.Model.Table fromTable = DaxModel.Tables.SingleOrDefault(t => t.TableName.Name == relationship.FromTable.Name); Dax.Model.Column fromColumn = fromTable.Columns.SingleOrDefault(t => t.ColumnName.Name == relationship.FromColumn.Name); Dax.Model.Table toTable = DaxModel.Tables.SingleOrDefault(t => t.TableName.Name == relationship.ToTable.Name); Dax.Model.Column toColumn = toTable.Columns.SingleOrDefault(t => t.ColumnName.Name == relationship.ToColumn.Name); Dax.Model.Relationship daxRelationship = new Dax.Model.Relationship(fromColumn, toColumn) { FromCardinalityType = relationship.FromCardinality.ToString(), ToCardinalityType = relationship.ToCardinality.ToString(), RelyOnReferentialIntegrity = relationship.RelyOnReferentialIntegrity, JoinOnDateBehavior = relationship.JoinOnDateBehavior.ToString(), CrossFilteringBehavior = relationship.CrossFilteringBehavior.ToString(), Type = relationship.Type.ToString(), IsActive = relationship.IsActive, Name = relationship.Name, SecurityFilteringBehavior = relationship.SecurityFilteringBehavior.ToString() }; DaxModel.Relationships.Add(daxRelationship); }
private void AddRole(Tom.ModelRole role) { Dax.Model.Role daxRole = new Role(DaxModel) { RoleName = new DaxName(role.Name) }; foreach (var tablePermission in role.TablePermissions) { Dax.Model.Table table = DaxModel.Tables.SingleOrDefault(t => t.TableName.Name == tablePermission.Table.Name); Dax.Model.TablePermission daxTablePermission = new TablePermission(daxRole) { Table = table, FilterExpression = DaxExpression.GetExpression(tablePermission.FilterExpression) }; daxRole.TablePermissions.Add(daxTablePermission); } DaxModel.Roles.Add(daxRole); }
internal Table(Dax.Model.Table table) { this._Table = table; }
internal VpaTable(Model.Table table) { this.Table = table; }