Dependent property and cascading delete in visual designer

2 posts, 0 answers
  1. test
    test avatar
    27 posts
    Member since:
    Feb 2008

    Posted 23 Nov 2010 Link to this post


    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 :

    And a metaclass "File" defined like this :

    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.

  2. Petko_I
    Petko_I avatar
    184 posts

    Posted 26 Nov 2010 Link to this post

    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,
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  3. DevCraft banner
Back to Top