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

Cascade delete not working through fluent mapping

1 Answer 40 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vikash
Top achievements
Rank 1
Vikash asked on 10 Dec 2015, 01:29 PM

Support Team,

I am trying to configure cascade delete for models through Fluent mapping and BackEnd configuration, but neither of them is working. I had already followed but with no luck http://docs.telerik.com/data-access/developers-guide/code-only-mapping/mapping-clr-types-properties-and-associations/advanced-mapping/multi-table-entities/fluent-mapping-mapping-clr-advanced-multi-table-entities-cascade-delete.

You can find sample application in the attachment for same to check the cause of it. Also, want to ask one more query, I have events on OpenAccessContext for Add/Delete/Update operation. I presume those should get triggered in a regular fashion in case of cascade delete as well, please let me know if you see any other problem with it.

https://drive.google.com/file/d/0B3uCMZI44TxJU2xjczY0cHpDZzg

Thank You,
Vikash Kumar.

1 Answer, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 14 Dec 2015, 03:32 PM
Hello Vikash,

If I understood correctly your scenario, you want when a "school" is deleted, all "teachers" associated to this "school" to be also deleted. If this is your scenario, you should set the IsDependent flag to the association between these classes. IsDependent flag should be set to association when you want to delete all of the child records of a parent record when the parent record is deleted. More information about IsDependent association you could find in this documentation article.
Cascading delete in Telerik Data Access should be used when you have a multi-table entity, which means one class to be mapped to more than one table, then when you delete the object through the context, all table which are mapped to this class should be cleaned. 

I hope that helps.

Regards,
Boris Georgiev
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
Development (API, general questions)
Asked by
Vikash
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
Share this question
or