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

Dependent property and cascading delete in visual designer

1 Answer 48 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
test
Top achievements
Rank 1
test asked on 23 Nov 2010, 03:14 PM
Hi,

I've a problem using the dependent property. I'm not using the ORM Classic but visual designer.

I want to delete a parent when I delete its child

I've a metaclass "Photography" defined like this :
PhotographyId
Name
FileId
File

And a metaclass "File" defined like this :
FileId
Url
Photographies

And an association between this 2 metaclasses : PhotographyHasFile, SourceMultiplicity : One, TargetMultiplicity : ZeroOne.

When i look to the relationships for the metaclass "Photography", I see my association between  my 2 metaclasses and check "managed" and "dependent" check boxes.

In my code, I load a photography using a fetchstrategy to get file informations too. When I do "dbcontext.delete(oPhotography)" I'm expecting the photography and its file are deleted but only the photography is deleted.

Could you explain why ? And how to do cascading delete with the new model of openacces.

Thanks for your help.


1 Answer, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 26 Nov 2010, 04:22 PM
Hi test,

As far as we can see, you have defined a relation between Photography and File which you would like to be one-to-one. OpenAccess currently does not support one-to-one associations and here is where the confusion comes. Under the cover the relationship between File and Photography is one-to-many. The Photography entity has a reference to a File, but the File entity has a collection of references (Photographies). The cascading delete will work if you delete a File - then all related Photographies will be deleted as well. If you reverse the relationship and let the Photography entity have a collection of Files and File has a property PhotographyID which relates to the identity of a Photography you will be able to implement a cascading delete on the part of the Photography.

Feel free to contact us, should you need any further assistance.

Best wishes,
Petko_I
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
Tags
Design Time (Visual Designer & Tools)
Asked by
test
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Share this question
or