Multiple field Identity / Cascade Delete

2 posts, 0 answers
  1. George
    George  avatar
    7 posts
    Member since:
    Sep 2006

    Posted 10 Jun 2010 Link to this post

    Hi Team,

    I don't know if this is the right place for this post. I have a tiny problem with OpenAccess and I'll appreciate it if you can help me solve it. I am sure it is a simple trick.

    So basically I am using Forward Mapping ... In my model I have a class called MediaLanguage having (int Id, IList<MediaLanguageLocalization> Localizations) and another class MediaLanguageLocalization(int Id, string cultureName, string Name, string Description)

    I have implemented the multiple field identity for this architecture using the IObjectId and it worked perfectly. The only problem that I have left is in the Cascade Delete ... I have set the Cascade delete option for the Localizations property but still everytime I delete my MediaLanguage entity the relevant entries from the "bc_MdLngg_bc_MdLnggLcalization" table get deleted but the entries in the table mapped to MediaLanguageLocalization remain intact.. 

    I am deleting the MediaLanguage entity using the following function: 
            public void Delete(int id) 
            { 
                var query = from item in Context.ObjectScope.Extent<MediaLanguage>() 
                            where item.Id == id 
                            select item; 
     
                if (query.Count() > 0) 
                { 
                    var entity = query.Single(); 
     
                    Context.ObjectScope.Remove(entity); 
                } 
            } 

    If I query the MediaLanguage that I have let's say for the english language after the deletion ... The Items are still there ... So the question is how can I make the Cascade delete to work properly ...

    Appreciate it in advance.

    G




  2. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 14 Jun 2010 Link to this post

    Hello G-force,
    This is a little complicated because we do not know about all your languages. The best way to do it by yourself, is to implement the IInstanceCallbacks interface at your persistent class. In the PreDelete you can delete all dependent data.

    To get the scope inside the persistent objects please call Database.GetContext(this).

    Best wishes,
    Jan Blessenohl
    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
Back to Top