New Posts New Posts RSS Feed: getting error when calling save on clean(?) entity
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

getting error when calling save on clean(?) entity

 Post Reply Post Reply
Author
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Topic: getting error when calling save on clean(?) entity
    Posted: 12-Aug-2009 at 9:34am
Hi Daniel, sorry to respond so late.   If you check e.IsCompleted or e.Result.SaveOperation first it will indicate the completion state and allow you to work around the problem with accessing e.Entities (which I think is a bug and will log).  You're right that the problem occurs when nothing was saved.
Back to Top
DanW View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Aug-2009
Posts: 6
Post Options Post Options   Quote DanW Quote  Post ReplyReply Direct Link To This Post Posted: 12-Aug-2009 at 5:50am
I have come up with a workaround of updating the "last updated" audit field that we have on all of our entities so that a save is forced, (which then causes an audit record to be generated in our audit log), so it's not a pretty solution, but I needed to get this process working.   
 
Thanks,
-Daniel


Edited by DanW - 12-Aug-2009 at 5:50am
Back to Top
DanW View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Aug-2009
Posts: 6
Post Options Post Options   Quote DanW Quote  Post ReplyReply Direct Link To This Post Posted: 10-Aug-2009 at 9:26am

Hello,  I have a routine that has a contact list, and can send an email from that list.  The list is a Sliverlight page, so I was using the AsyncSerialTask to handle the save & send calls, but I ran into an error when I am testing it from the actual silverlight page.. Here is the Async task,  

public void SendContact(DealConfContacts dealConfContacts, AsyncCompletedCallback<InvokeServerMethodEventArgs> callback)
        {
            IList<DealConfContacts> confContacts = new List<DealConfContacts>();
            confContacts.Add(dealConfContacts);
            SaveOptions saveOpt = new SaveOptions();
         
            var task1 = AsyncSerialTask.Create();
            task1.AddExceptionHandler(TestAsyncSerialTaskSerialExceptionHandler);
            var task2 = task1.AddAsyncSave(Manager, confContacts, saveOpt);

            // This was original save, switched to AddAsyncSave, both error in same place
            //var task2 = task1.AddAsyncAction<EntitySavedEventArgs>((serialArgs, callBackTo) => Manager.SaveChangesAsync(confContacts,callBackTo,null));
            var task3 = task2.AddAsyncAction<InvokeServerMethodEventArgs>((serialArgs, callBackTo) => DealConfContactsAsyncBehaviors.SendConfirmAsync("SYSTEM", Manager, dealConfContacts.DealConfirmation, dealConfContacts, "email", callBackTo));
            task3.Execute(callback);
        }

The error shows up here when the e.entities is accessed.  For the record, the entity may or may not have been dirty at this point, could that be the reason for the error? that the entity was clean when save was called? (I was hoping to write one stack that could save/create the entity, but if I need to differentiate before this point if it is not saved, please let me know.)

     void DomainModelEntityManager_Saved(object sender, EntitySavedEventArgs e)
        {
            if (!e.Cancelled)
            {
                if (e.Entities != null)
                {
                    foreach (object item in e.Entities)
                    {
                        var savedItem = item as ISaved;
                        if (savedItem != null)
                            savedItem.SavedHandler();
                    }
                }
            }
        }

Here is the error that I am seeing:

System.ArgumentNullException was unhandled by user code
  Message="Value cannot be null.\r\nParameter name: source"
  StackTrace:
       at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)
       at IdeaBlade.EntityModel.EntitySavedEventArgs.get_Entities()
       at GcsAg.DomainModel.DomainModelEntityManager.DomainModelEntityManager_Saved(Object sender, EntitySavedEventArgs e)
       at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
       at IdeaBlade.EntityModel.EntityManager.OnSaved(EntitySavedEventArgs args)
       at IdeaBlade.EntityModel.EntityManager.<SaveChangesAsyncCore>b__3c(EntitySavedEventArgs args)
       at IdeaBlade.EntityModel.AsyncProcessor`1.<Execute>b__1(Object x)
  InnerException:

thanks,
-DanW
 


Edited by DanW - 10-Aug-2009 at 11:57am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down