QDSCV remove item

5 posts, 0 answers
  1. Anton
    Anton avatar
    6 posts
    Member since:
    Nov 2014

    Posted 25 Nov 2014 Link to this post

    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)
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Nov 2014 Link to this post

    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:
    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.

     
  3. DevCraft banner
  4. Anton
    Anton avatar
    6 posts
    Member since:
    Nov 2014

    Posted 26 Nov 2014 in reply to Dimitrina Link to this post

    This code for empty collection raised exception at 2nd line:

    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.

  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Nov 2014 Link to this post

    Hello,

    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.

     
  6. Anton
    Anton avatar
    6 posts
    Member since:
    Nov 2014

    Posted 27 Nov 2014 in reply to Dimitrina Link to this post

    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.
Back to Top
DevCraft banner