I have a grid and dataset object connected with it.
And datalayer working with LINQ. So I need to delete elements that was deleted in grid from LINQ data source.
I have a method that convert my DataRow item to LINQ item. For example:
DataRow forDelete = ...;
LinqItem itemForDelete = ConvertFromDataRow(forDelete);
dataContext.DeleteOnSubmit(itemForDelete);
this code throw an exception, that imposible to delete item who is not attached to table.
But if I change it to
DataRow forDelete = ...;
LinqItem itemForDelete = ConvertFromDataRow(forDelete);
dataContext.Attach(itemForDelete)
dataContext.DeleteOnSubmit(itemForDelete);
than it will throw exception that it’s impossible to attach item, which already exist.
Question will be how to attach an item properly in that case. That should solve the problem.
Looks like there are no correct answer on that question or no way to do what I need.