QDSCV - removing entity from a entity collection

6 posts, 0 answers
  1. Frank
    Frank avatar
    12 posts
    Member since:
    May 2011

    Posted 30 Jun 2011 Link to this post

    Hi,

    my problem is that when I am trying to delete an entity from an EntityCollection within the QDSCV and after that call the QDSCV.SubmitChanges method I am always getting an "Submit Error Not Handled"-Error. If I handle the error (e.MarkErrorAsHandled) the item is not removed. 

    For expamle:

    I have a Person that can have many Orders.
    If my QDSCV is from type Person there will be an EntityCollection in it from type Order. If now remove a selected order from that collection I will get this error:

    public void RemoveOrderFromPeople(Order order)
    {
                    foreach (Person person in People.Where(p => p.Orders.Contains(order)))
                    {
                        person.Orders.Remove(order);
                    }
     
                    People.SubmitChanges();
    }

    How can I remove that entity from the collection, without getting this error but the item deleted from the db?


    Thanks in advance!

    Best wishes,
    Julian


  2. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 01 Jul 2011 Link to this post

    Hello Frank,

    Could you provide me with a little bit more information about the error?
    Could you confirm that you do not have some foreign key that blocks delete operation on a Person with Orders?

    Best wishes,
    Nedyalko Nikolov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Frank
    Frank avatar
    12 posts
    Member since:
    May 2011

    Posted 01 Jul 2011 Link to this post

    Here are some more information for you.

    Error:
    Submit error is not handled!

    Error Details
    at Telerik.Windows.Data.QueryableDomainServiceCollectionView`1.OnDomainContextSubmittCompleted(SubmitOperation submitOperation)
       at System.ServiceModel.DomainServices.Client.SubmitOperation.InvokeCompleteAction()
       at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error)
       at System.ServiceModel.DomainServices.Client.SubmitOperation.Complete(OperationErrorStatus errorStatus)
       at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClassb.<SubmitChanges>b__3(Object )


    I attached a model of a part of my DB (simplified). An ElectricInput cannot exist without a Plant. 

    //Edit: Just updated the attached file. Please view newmodel.png !
  5. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 01 Jul 2011 Link to this post

    Hi Frank,

    You can hook for the QDSCV.SubmittedChanges event and get more information about the error. I'm attaching an image for a reference.

    Greetings,
    Nedyalko Nikolov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Diego
    Diego avatar
    1 posts
    Member since:
    Jun 2014

    Posted 22 Jun 2014 Link to this post

    In the case i  have some foreign key that blocks delete operation, what can i do ?
  7. Nick
    Admin
    Nick avatar
    593 posts

    Posted 23 Jun 2014 Link to this post

    Hi Diego,

    This case is a very common scenario and there are a couple of solutions you can try. 

    The first one and the most common one is to enable the Cascade delete in your DataBase designer(SQL management studio). This will take care of the problem out of the box and will prevent the error from being shown.

    The second approach is to manually dispose of any dependencies prior to deleting the needed entity. 

    Hope this helps. 

    Regards,
    Nik
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
DevCraft banner