我尝试用相同的数据更新两次,但它抛出异常
public void UpdateOnSubmit<T>(T data) where T : class
{
lock (_lockObj)
{
using (DataModel dx = new DataModel(this._adapter.ConnectionString))
{
dx.GetTable<T>().Attach(data);
dx.Refresh(RefreshMode.KeepCurrentValues, data);
dx.SubmitChanges();
}
}
}
例外是
An attempt has been made to Attach or Add an entity that is not new, perhaps having been loaded from another DataContext. This is not supported.
第一次更新是成功的,但不是第二次。提前致谢
问候,
布赖恩