System.Data.Linq.ChangeConflictException: Row not found or changed

后端 未结 19 2816
生来不讨喜
生来不讨喜 2020-12-07 22:21

I am trying to delete a selected gridview row using LINQ (No LINQDataSource).

When the selection is changed, the detailsview binding is changed also. I can add a new

19条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 23:00

    I had a similar problem and although deleting and re-adding the DBML table/class helped some users, for me it was a bit different since I'm using WCF with detached entity and a ListView on the client.

    If I used the .Attach(entity) it failed - "Row not found or changed" But when using .Attach(entity, original) it works every time

    public void DeleteTask(Task task)
        {
            TwoDooDataContext db = new TwoDooDataContext();
            db.Tasks.Attach(task,GetTaskByID(task.ID));
            db.Tasks.DeleteOnSubmit(task);
            db.SubmitChanges();
        }
    

提交回复
热议问题