New Posts New Posts RSS Feed: When deleting an entity have to call the repository twice?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

When deleting an entity have to call the repository twice?

 Post Reply Post Reply
Author
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Topic: When deleting an entity have to call the repository twice?
    Posted: 03-Oct-2012 at 9:37am
Hello,
suppose I've got an entity VARIABLES and I delete it doing
 
OperationResult DeleteVariables(VARIABLES v)
{
v.EntityAspect.Delete();
 
return AlwaysCompletedOperationResult.Instance
 
then at the Operation.CompletedSuccessfully call :
 
public OperationResult SaveAsync(Action onSuccess = null, Action<Exception> onFail = null)
     {
         EntitySaveOperation op = entityManagerProvider.Manager.SaveChangesAsync();
         return op.OnComplete(onSuccess, onFail).AsOperationResult();
     }
 
Or there's a simpler way in SL?
Thanks
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 03-Oct-2012 at 10:28am
You have to delete and save, because until you save, it is only deleted in memory.

However, when you switch to DF2012 and VS 2012, the syntax is much easier

you can simply do something like:

public async void Delete()
{
   myEntity.Delete();
   await SaveAsync();
}

public async Task SaveAsync()
{
            return entityManagerProvider.Manager.SaveChangesAsync();
}


Edited by smi-mark - 03-Oct-2012 at 10:29am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down