Skip to content

Changing name by FixExpression #65

@Felipo17

Description

@Felipo17

I have specific situation when tabels in my model are named like this: [0] Calendar, [1] Products, [EF] EquipmentFailure, etc (anything can be inside of square brackets). I made rule that checks if table name starts with "[" and if yes it suggest it to change. Now I want to apply a change that my Tables will be named like this: 0_Calendar, 1_Products, EF_EquipmentFailure and I want to make some FixExpression to do it automatically. Right now my JSON rule looks like this:
{
"ID": "AVOID_SQUARE_BRACKETS_AT_THE_BEGINNING_OF_TABLE_NAMES",
"Name": "Avoid square brackets at the beginning of table names",
"Category": "Naming Conventions",
"Description": "Table names should not start with a square bracket (e.g [1] Sales). Consider renaming to avoid compability issues or confusion.",
"Severity": 2,
"Scope": "Table, CalculatedTable",
"Expression": "Name.StartsWith("[") and Name.IndexOf("]") > 1 and Columns.Count > 1",
"FixExpression": "ObjectName = ObjectName.Substring(1, ObjectName.IndexOf("]") - 1) + "_" + ObjectName.Substring(ObjectName.IndexOf("]") + 2)",
"CompatibilityLevel": 1200
},
but it gave me errors :

  • error CS1061: The type TabularEditor.TOMWrapper.Table does not contain a definition for ObjectName, and no accessible extension method ObjectName accepting a first argument of type TabularEditor.TOMWrapper.Table could be found.
  • error CS0103: The name ObjectName does not exist in the current context.
    And I don't really know if there is any solution that can change my problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions