Collection

Sachin_Kharmale

Active Member
Hi @janejeba ,

For Transpose the collection as per your requirement design flow and
code stage in object studio as bellow,

1. Main Flow in Object Studio.
View attachment 1579149569985.png
2. your Input Collection With Values.
View attachment 1579149603819.png
3. Code Stage Input.
View attachment 1579149626587.png
4. Code Stage Output.
View attachment 1579149644123.png
5. Code Stage Code.
View attachment 1579149672907.png

6. Output Collection after execution of code.
View attachment 1579149705721.png

C#:
            DataTable outputTable = new DataTable("OutputTable");
            List<int> lst = new List<int>();
            foreach (DataRow row in InputTable.Rows) {
                outputTable.Columns.Add(new DataColumn(""+row["Name"], Type.GetType("System.String")));
                lst.Add(Convert.ToInt32(row["Age"]));
            }
            DataRow newRow = outputTable.NewRow();
            for(int i=0; i< lst.Count;i++) {
                newRow[outputTable.Columns[i]] = lst[i];
            }
            outputTable.Rows.Add(newRow);
            ResultCollection=outputTable;
I hope it will help you,.,!

 

janejeba

Member
When in click the Check code button it shows zero errors. But when I tried to execute I’m getting “Object Reference Error”

I don’t have access to share screen shot. I’m sure that no mismatches in i/p and o/p names.
 
Last edited:

janejeba

Member
Hi Sachin,

I have shared the screen shots here..
 

Attachments

  • Error Message.PNG
    15.2 KB · Views: 13
  • Code Window.PNG
    12.5 KB · Views: 10
  • Input.PNG
    21.9 KB · Views: 10
  • Output.PNG
    22.5 KB · Views: 11

janejeba

Member
Is it mandatory to add any DLL & name spaces for writing code in c#. This is the first time I'm using code stage with c#
 

janejeba

Member
Hi Sachin,

Finally It worked . Thanks for your support. I have added the DLL & namespaces listed in the attachment you shared.
 
Top