0
我嘗試使用相同的數據兩次更新,但它拋出異常LinqToSQL無法更新兩次
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.
首先更新是成功的,但不是在第二位。在此先感謝
問候,
布賴恩