Update records without the Update method

I have been going through the EF 6 tutorials and one comment that stands out is not to create an Update method.

When i search around everyone else has the Update method so imagine i have the below scenario:

public static void Swap<T>(IList<T> list, int indexA, int indexB)
    T tmp = list[indexA];
    list[indexA] = list[indexB];
    list[indexB] = tmp;

In my application i get the records

List<Customer> tempList = _uow.Customers.GetAll();

tempList.Swap(1,2); // Records have swapped here and is correctly working

_uow.Save(); // Changes are never updated on the database.

So do i need to make a second call to the database in order to update change the two records (as i already called called GetAll to get the records from the DB)? I’ve used the PlutoContext project as a guide when building this method?

Since you are not changing any of your customers none are updated. Just swapping the order of the customers in your collection doesn’t change the customer data itself.

Try changing a customer’s name instead and it will be updated in the database when calling Save().