I am developing a web application using c#. I am reading some data from database to a data table named dt . Sample data is shown below.
agentName WeekNumber Score
John 3 45
John 5 78
John 6 33
I want to make some change in the above data based on some conditions. Cause i want to draw a graph based on this data.The agent name is always same.and the week field is unique. I want to make a new data table using conditions listed below.
1-The new data table week field must start from 1.If there is no entry in the data table for week 1, you can add the data into new data table as shown below
John 1 0
it means just give 0 as score.
2-If there is any missing weeks from second row onwards in the data table obtained from database , add the row for that week with score as -1.
in the above example after first row there is a missing week 4. so add it to new data table with score -1
the new data tab;e for sample data is shon below
agentName WeekNumber Score
John 1 0
John 2 0
John 3 45
John 4 -1
John 5 78
John 6 33
How can i do it in an efficient method using c#? The number of rows will vary .
I want to do it using c# . not by using queries because of some reason
you can use the following class and the build a new table from it.