0

I have a list of objects returning from a function. How I can traverse the list and modify some objects, like append a specific string to all cells (integers) of a specific column? I could also add 2 more string columns: sid_s and num_s if its easier...

List<object> data = (from q in dc.Queries
                                 join ss in dc.Sites on q.SiteId equals ss.Siteid
                                 where q.CTid == 100
                                 select new
                                 {
                                     s.id, //integer to string
                                     q.name,
                                     q.num
                                 }).ToList<object>();

Here is my list:

sid | name | num

100 | a | 2001

101 | b | 2002

I want to change it to:

sid | name | num

100qq | a | 2001zz

101qq | b | 2002zz

OR

sid | name | num | sid_s | num_s

100 | a | 2001| 100qq |2001zz

101 | b | 2002| 101qq |2002zz

aggelos
  • 67
  • 1
  • 11

1 Answers1

1

Use foreach and loop through the list :

foreach(MyObject obj in myList)
{
   obj.yourProp1 = "newValue";       
}
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396