This is puzzling me. I’m using PetaPoco to retreive some values from a database, and then looping over them and retrieving a value to assign to one of the properties of each object.
public IEnumerable<RetreaveIndex> FillResults(IEnumerable<RetreaveIndex> results)
{
//add the associated users
foreach (RetreaveIndex index in results)
{
index.AssociatedUsers = _registeredUserDao.GetUsersByIndex(index).ToList();
}
return results;
}
When I set a breakpoint during the foreach loop, the AssociatedUsers property is being set correctly.

but then in a breakpoint at the end of the loop, it didn’t save it?

I’m confused, shouldn’t Index be a reference to a place in memory which is being modified? It’s an object after all. What am I missing here?
What is the IEnumerable implementation? Could it be returning a copy of the object?
Is RetreaveIndex a struct, and thus a value type? If so, then the variable
indexwill be a copy.