I am trying to remove entities from QDSCV.
Currently I use QDSCV.RemoveAt(index) method.
When I remove entity loaded from server - it work as expected.
But when I trying to remove newly added item (QDSCV.AddNew() and then QDSCV.RemoveAt()) then exception raised:
"The specified entity is not contained in this EntitySet"
What is the right way to remove newly added items from QDSCV?
(v.Q1-2013)
Currently I use QDSCV.RemoveAt(index) method.
When I remove entity loaded from server - it work as expected.
But when I trying to remove newly added item (QDSCV.AddNew() and then QDSCV.RemoveAt()) then exception raised:
"The specified entity is not contained in this EntitySet"
What is the right way to remove newly added items from QDSCV?
(v.Q1-2013)
4 Answers, 1 is accepted
0
Hi,
Most probably the exception is thrown because the item you are trying to remove does not exist in the particular EntitySet. Therefore the specified item cannot be deleted from it.
You can avoid this adding an additional check before removing the item to assure it is indeed presented in this EntitySet.
For example:
Regards,
Dimitrina
Telerik
Most probably the exception is thrown because the item you are trying to remove does not exist in the particular EntitySet. Therefore the specified item cannot be deleted from it.
You can avoid this adding an additional check before removing the item to assure it is indeed presented in this EntitySet.
For example:
if
(QC1.Contains(item)
{
this
.QC1.Remove(item);
}
Regards,
Dimitrina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Anton
Top achievements
Rank 1
answered on 26 Nov 2014, 06:10 AM
This code for empty collection raised exception at 2nd line:
Note: Newly added item created in separate DomainContext (different from QDSCV DomainContext). After QC1.AddNew method call, the new item appeared in QC1 collection and in QC1.SourceCollection. But it does not exists in corresponding EntitySet behind the QC1 DomainContext.
this
.QC1.AddNew(item);
this
.QC1.RemoveAt(0);
//"The specified entity is not contained in this EntitySet" exception here
Note: Newly added item created in separate DomainContext (different from QDSCV DomainContext). After QC1.AddNew method call, the new item appeared in QC1 collection and in QC1.SourceCollection. But it does not exists in corresponding EntitySet behind the QC1 DomainContext.
0
Hello,
Have you tried committing the changes (adding new item) before trying to remove any of it?
For example:
Regards,
Dimitrina
Telerik
Have you tried committing the changes (adding new item) before trying to remove any of it?
For example:
this
.QC1.AddNew(item);
this
.QC1.CommitNew()
this
.QC1.RemoveAt(0);
Regards,
Dimitrina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Anton
Top achievements
Rank 1
answered on 27 Nov 2014, 06:55 AM
Yes I have used QC1.CommitNew() but with the same result.
OK. It seems that QDSCV have significant drawbacks/bugs related to editing.
So I solved this another way.
Now I use QDSCV for paged vew only. When I need to modify collection I copy current QDSCV page to ObservableCollection<T> and then rebind this collection as RadGridView` data source.
ObservableCollection<T> have all editing abilities I need.
OK. It seems that QDSCV have significant drawbacks/bugs related to editing.
So I solved this another way.
Now I use QDSCV for paged vew only. When I need to modify collection I copy current QDSCV page to ObservableCollection<T> and then rebind this collection as RadGridView` data source.
ObservableCollection<T> have all editing abilities I need.