I came across this Linq to Sql code in an application I am maintaining:
dbDataContext db = new dbDataContext();
db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
dbDataContext is the class that inherits System.Data.Linq.DataContext
In this example, the code is trying to refresh the entire DataContext, but it is called immediately after instantiation of the DataContext. Isn’t this redundant?
Also, the Refresh call appears to be calling this overload of the method without a second parameter. Since there is no parameter specified, there is no object to refresh. So does this call to Refresh have any purpose without a second parameter?
I finally got around to using Telerik JustDecompile to look at the .NET code and see if there is any purpose in calling Refresh with no second parameter.
A missing second parameter defaults to an array with 0 items. Therefore, the refresh logic takes an early exit once it hits the for..each block. None of the items are then refreshed.
In conclusion, calling the Refresh method with a blank second parameter will not refresh any items in the DataContext.