When I’m trying to use following codeblock:
private MarketingDBDataContext DB_Marketing;
public DBFacade()
{
DB_Marketing = new MarketingDBDataContext();
}
public void updateSingleObj(object obj)
{
if (obj is Marketing.Cust)
{
try
{
DB_Marketing.Refresh(RefreshMode.OverwriteCurrentValues, obj);
}
catch (Exception ex)
{
}
}
}
I’m getting this Exception:
An object specified for refresh is not recognized
I have a similar method with another datacontext and another entity object reference, which works fine.
I have a Marketing Cust gui, that open a new dialogwindow for entering website link. I want to check the current Marketing Cust object for change in this Weblink value, before the new DialogWindow show up.
Found the problem.
Having two controllers where each having an instance of the Database facade. I try’d to re-use a method in the wrong controller, forgetting that the controller make and database facade instance for the corresponding database, which ofcause led to a DataContext, where the object didn’t exist.
My tip for others, check where you instantiate your DataContext, and make sure that the object contain in it.