This question is locked. New answers and comments are not allowed.
In my application using QDSCV I simply add a new entity via "AddNew(...)". If the user cancels this adding operation I call "CancelNew()" which leads to an error.
I investigated the error a little bit and found out that in "DomainServiceCollection" the "OnCollectionChanged" event is triggered trying to remove the item from the EntitySet, But: the item has never been added to the underlying EntitySet. When adding items the same "OnCollectionChanged" event is called and it tries to add the new item to the EntitySet. Unfortunately it is checking for "EntityState.Detached" instead of "EntityState.New" which is the EntityState the newly added item is in. Thus it is NOT in the EntitySet and the remove operation later on crashes.
Also in my opinion the line "totalItemCount++" belongs in between the brackets under the Add-statement - why should the totalItemCount be increased if not item has been added to the entitySet?
Regards
Neils
I investigated the error a little bit and found out that in "DomainServiceCollection" the "OnCollectionChanged" event is triggered trying to remove the item from the EntitySet, But: the item has never been added to the underlying EntitySet. When adding items the same "OnCollectionChanged" event is called and it tries to add the new item to the EntitySet. Unfortunately it is checking for "EntityState.Detached" instead of "EntityState.New" which is the EntityState the newly added item is in. Thus it is NOT in the EntitySet and the remove operation later on crashes.
foreach
(TEntity item
in
e.NewItems)
{
if
(item.EntityState == EntityState.Detached)
{
entitySet.Add(item);
}
this
.totalItemCount++;
}
Also in my opinion the line "totalItemCount++" belongs in between the brackets under the Add-statement - why should the totalItemCount be increased if not item has been added to the entitySet?
Regards
Neils