Print Page | Close Window

Sorry, recursive saves are not supported.

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2505
Printed Date: 29-Jul-2026 at 1:28pm


Topic: Sorry, recursive saves are not supported.
Posted By: mikewishart
Subject: Sorry, recursive saves are not supported.
Date Posted: 11-Feb-2011 at 7:18pm
Just had to post that very nice polite error message!

In the EntityServerSaveInterceptor, I want to clean up potential orphans by deleting the records AFTER the base.ExecuteSave() has been called.  After all, they may have already cleaned up the orphaned records, or perhaps they modified associated entities in such a way that they aren't orphans.

      var orphans = EntityManager.GetQuery<OrphanTable>()
        .With(QueryStrategy.DataSourceOnly)
        .Where(somePredicate)
        .ToList();

      foreach (var orphan in orphans)
        orphan.EntityAspect.Delete();

      EntityManager.SaveChanges(orphans);

The last line is where I get the error.  Any chance of getting it to save further updates?

Thanks!




Replies:
Posted By: DenisK
Date Posted: 14-Feb-2011 at 1:55pm
Hi mikewishart;

Could you elaborate further on your use case here? I'm still unclear why you want to perform a delete operation inside the save interceptor. If you want to perform a delete after a save, why can't you do it outside the interceptor, for example, after the mgr.SaveChanges call?


Posted By: mikewishart
Date Posted: 14-Feb-2011 at 2:01pm
We have a table of tasks associated with objects in a certain state.  If, for whatever reason, the objects change state the tasks are no longer valid.  This is more of a proactive thing where the tasks should be deleted within the same transaction as changing the object's state, but rather than tracking down every related bug, we can write a general purpose query to do this and not worry about it.


Posted By: DenisK
Date Posted: 15-Feb-2011 at 11:14am
mikewishart;

I had a discussion with a senior engineer about your use case. Here are her suggestions.

1. Consider doing the deleting of the tasks before the base.ExecuteSave, if possible, since those deletes will all then be included in the save.

2. Or consider using db triggers instead of DevForce.

3. Or consider listening for entity changes and "trigger" the deletes on the client.

Hope this helps.


Posted By: mikewishart
Date Posted: 15-Feb-2011 at 9:57pm
Thanks Denis.  For now I changed it to just be straight SQL ala ADOHelper.  Later I may try and change it to be option #1 for better performance.



Print Page | Close Window