I have a datagridview bound to a table that is part of an Entity Framework model. A user can edit data in the datagridview and save the changes back to SQL. But, there is a stored procedure that can also change the data, in SQL, not in the datagridview. When I try to "refresh" the datagridview the linq query always returned the older cached data. Here's the code that I have tried using to force EF to pull retrieve new data:
// now refresh the maintenance datagridview data source
using (var context = new spdwEntities())
var maintData =
from o in spdwContext.MR_EquipmentCheck
where o.ProdDate == editDate
orderby o.Caster, o.Strand
mnt_DGV.DataSource = maintData;
I've seen a number of posts suggesting this method, but it didn't work for me. When I debug, I can see that the SQL table has the updated data in it, but when this snippet of code runs, maintData has the old data in it.
I've had this problem with a couple of other datagridviews and I solved it with a really ugly work-around (which I refuse to initial). I need to clean all of them up. So, I'd really appreciate some help.