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 returns the older cached data. Here's the code that I have tried using to force EF to return 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
select o;
mnt_DGV.DataSource = maintData;
}
I've seen a number of posts suggesting this method, but it didn't work for me. When In 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. I need to clean all of them up. So, I'd really appreciate any suggestions.
contextbut then usespdwContext