I am trying to understand something with change tracking in FE6.
I have code similar to this one.
public class SomeClass { private List<User> _users; private DAL _dal; public void ProcessUsers() { _users = _dal.GetUsers(); foreach(var u in users) { u.user.Comment = "This is a test"; } _dal.SaveChanges(); } }
The DAL class looks something like this.
public class DAL { ... private DataContext _context;
So, as we see from the code in the ProcessUsers method, we have a list of users, and we modify this list.
Now I know that this works. His way that I always did this, however, I was always impressed that the objects in the list (users in this case) were a link to the corresponding object in the local DBSet database,
After some thought, Iโm not sure if itโs as if the context was configured, the list is still full and can be managed (we just lose the ability to return it back to the database without any additional work), therefore, from this point of view, the elements in the list should be copies of the items from the DBSet Local collection ... but if so, I wouldnโt do it, although manipulating the object in the list would affect the object in dbset, since it would be a copy.
In summary
The question is what happens when I call ToList on a DBSet, and how does change tracking work in this case? โI know this works, but I think my current understanding may be wrong.โ