I am facing a challenge in returning data from the SQL server to the view. My question is about how to dynamically return column titles from the database to a table in an Angular app view. As new entries are added to the person table in the database, new columns with corresponding names should be added to the pivot table.
On the server side, I am using C# ASP.NET WebAPI 2 and SQL Server 2012, while on the client side, I am utilizing AngularJS.
The REST Service integrates with a Stored Procedure in the SQL Server.
For example, the standard table structure looks like this:
firstname | lastname | age |
John | Doe | 20 |
Peter | Keller| 19 |
Chris | Brown | 30 |
Christy | Buzzy | 20 |
Phil | Brown | 34 |
.....
And the PIVOT table format is as follows:
age | Doe | Keller | Brown | Buzzy ....
34 | 0 | 1 | 1 | 0
...
30 | 4 | 0 | 1 | 0
...
20 | 1 | 0 | 0 | 0
This table shows, for instance, that there are 4 people aged 30 with the last name "Doe" and so on.