LINQ to SQL does not update when data has changed in database

后端 未结 2 1622
野趣味
野趣味 2020-12-11 15:27

I have this problem where after a field (say Field3 in table MyTable) is updated on the database, MyTable.Field3 (in C#) is still returning the old value.

2条回答
  •  再見小時候
    2020-12-11 15:35

    DataContext.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, entity);
    

    If you want to refresh your entire entity set, the easiest way is probably to just create a new DataContext and requery for everything.

提交回复
热议问题