I call a stored procedure from my code and it returns a
IEnumerable<dynamic> data
with 3 properties
I would like to be able to modify one of a value of the data var for example
data[2].ID = 6687687
Do you know how to do this please?
You can access individual elements by using the ElementAt method like this:
data.ElementAt(2).ID = 6687687;
However, this is not efficient since it will iterate through the enumerable until it reaches the required index. And sometimes the enumerable that you get will execute some query every time your enumerate it. This means that you will get new objects every time you enumerate it (e.g. via ElementAt).
A better way is to convert the enumerable to a list like this:
var list = data.ToList();
And then access the elements by index like this:
list[2].ID = 6687687;
ID property as an integer?