This is a migrated thread and some comments may be shown as answers.

QDSCV - removing entity from a entity collection

5 Answers 189 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 30 Jun 2011, 02:22 PM
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


5 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 01 Jul 2011, 12:48 PM
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
0
Frank
Top achievements
Rank 1
answered on 01 Jul 2011, 01:42 PM
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 !
0
Nedyalko Nikolov
Telerik team
answered on 01 Jul 2011, 02:59 PM
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
0
Diego
Top achievements
Rank 1
answered on 22 Jun 2014, 08:27 PM
In the case i  have some foreign key that blocks delete operation, what can i do ?
0
Nick
Telerik team
answered on 23 Jun 2014, 08:26 AM
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.
 
Tags
DomainDataSource
Asked by
Frank
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Frank
Top achievements
Rank 1
Diego
Top achievements
Rank 1
Nick
Telerik team
Share this question
or