Esempio n. 1
0
        public CalculatedTableColumn AddCalculatedTableColumn(string name = null, string sourceColumn = null, string displayFolder = null, DataType dataType = DataType.String)
        {
            if (!Handler.PowerBIGovernance.AllowCreate(typeof(CalculatedTableColumn)))
            {
                throw new PowerBIGovernanceException("Adding columns to a table in a Power BI model is not supported.");
            }

            Handler.BeginUpdate("add Calculated Table column");
            var column = CalculatedTableColumn.CreateNew(this, name);

            column.DataType = dataType;
            if (!string.IsNullOrEmpty(sourceColumn))
            {
                column.SourceColumn = sourceColumn;
            }
            if (!string.IsNullOrEmpty(displayFolder))
            {
                column.DisplayFolder = displayFolder;
            }
            Handler.EndUpdate();
            return(column);
        }
Esempio n. 2
0
        public CalculatedTableColumn AddCalculatedTableColumn(string name = null, string sourceColumn = null, string displayFolder = null, DataType dataType = DataType.String)
        {
            if (Handler.UsePowerBIGovernance && !PowerBI.PowerBIGovernance.AllowCreate(typeof(CalculatedTableColumn)))
            {
                return(null);
            }

            Handler.BeginUpdate("add Calculated Table column");
            var column = CalculatedTableColumn.CreateNew(this, name);

            column.DataType = dataType;
            if (!string.IsNullOrEmpty(sourceColumn))
            {
                column.SourceColumn = sourceColumn;
            }
            if (!string.IsNullOrEmpty(displayFolder))
            {
                column.DisplayFolder = displayFolder;
            }
            Handler.EndUpdate();
            return(column);
        }