Page 1 of 1

Renaming data column / business object property

Posted: Thu Jun 11, 2015 8:44 am
by Tobias
Is there an easy way to rename data columns and business object properties and all there usages in a *.mrt file (by code, not manually)?

e.g. having a BO:

Code: Select all

class Foo
{
   string FooNumber {get; set;}
   string FooName {get; set;}
}
...
report.RegBusinessObject("Foo", new Foo{..});
...
I now want to rename Foo into Bar and FooNumber/FooName into BarNumber/BarName without the need to manually open the *.mrt in the designer and replace all usages ("{Foo.FooNumber}" and so on).

Re: Renaming data column / business object property

Posted: Fri Jun 12, 2015 1:26 pm
by HighAley
Hello.

You could use next code to change names of properties:

Code: Select all

            report.RegBusinessObject("Foo", new Foo{FooNumber = "1", FooName = "Name"});
            report.Dictionary.SynchronizeBusinessObjects();
            report.Dictionary.BusinessObjects["Foo"].Columns["FooNumber"].Name = "BarNumber";
            report.Dictionary.BusinessObjects["Foo"].Columns["FooNumber"].NameInSource = "FooNumber";
Thank you.

Re: Renaming data column / business object property

Posted: Fri Jun 12, 2015 3:32 pm
by Tobias
Ok thanks.
But I think Name and NameInSource must be switched in your solution to make this work. But it's not exactly what I had in mind. I really need to change the Name of a column, not just the "NameInSource". I hoped there migth by some kind of parser hidden somewhere in the API which allows me to take the mrt and simply replace all the column references or to simply iterate over all column refernces and change them.

Re: Renaming data column / business object property

Posted: Mon Jun 15, 2015 1:23 pm
by Alex K.
Hello,

Unfortunately, there is no a simple solution.
As a way, you can open template report as text file and use string.Replace

Thank you.

Re: Renaming data column / business object property

Posted: Mon Jun 15, 2015 2:43 pm
by Tobias
Ok, thanks! I'll probably use XMLReader and search/replace all column references.

Re: Renaming data column / business object property

Posted: Tue Jun 16, 2015 5:35 am
by Alex K.
Hello,

Ok.
Let us know if you need any additional help.

Thank you.