Hi,
I'm using LINQ.. and I would like to understand if it's a bug or not
in LINQ...
I've a situation like: I'm reading all records via "Select" Statement
and a specific select statment #1 record retrieves the record and
propose for Delete or Update... when I make changes and click on
Update I get "DuplicateKeyEx ception Cannot add an entity with a key
that is already in use. "
I googled and I found the following statement " ...when you use the
same DataContext for CUD as it does for Select. As a result, if a
Select is performed before an Update or Delete then the Update or
Delete will fail. This is because the data objects are already loaded
in the DataContext's cache from the previous query, so the Attach call
made by LDS is not valid.
This will be fixed so that LDS uses separate DataContexts for CUD
operations in the next release.
So my question is: Did someone have had the same situation?
objDataContext = DatabaseFactory .GetLinq();
objDataContext. F4102s.Attach(L ocalTable); ---it
DUMPS HERE....
objDataContext. Refresh(Refresh Mode.KeepCurren tValues,
LocalTable);
objDataContext. SubmitChanges(C onflictMode.Con tinueOnConflict );
see link below for the the statement....
http://forums.asp.net/t/1203078.aspx
any idea how I can avoid duplicate key error when I do Updates)
-mesut