New Posts New Posts RSS Feed: ArgumentNullException in EntityManager Saved Event
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

ArgumentNullException in EntityManager Saved Event

 Post Reply Post Reply
Author
sebma View Drop Down
Groupie
Groupie
Avatar

Joined: 19-Aug-2008
Location: Singapore
Posts: 66
Post Options Post Options   Quote sebma Quote  Post ReplyReply Direct Link To This Post Topic: ArgumentNullException in EntityManager Saved Event
    Posted: 11-Jun-2010 at 2:53am
Hi all,
 
Not sure if anyone encountered ArgumentNullException being thrown if you pass in an empty list to EntityManager.SaveChanges(emptyList) and then try to handle an EntityManager Saved event.
 
I now have to try...catch accessing e.Entities :(
 
        private static void EntityManager_Saved(object sender, EntitySavedEventArgs e)
        {
            if (e == null || e.Error != null)
                return;
            IList<object> ents = null;
            try
            {
                ents = e.Entities;
            }
            catch (ArgumentNullException)
            {
                // what happened ???
            }
 
            if (ents == null || ents.FirstOrDefault() == null)
                return;
            ...
        }
 
 
 
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 11-Jun-2010 at 8:15pm
Yes, I believe we have confirmed this as a bug.  The try/catch block is the workaround until this is fixed.  Sorry for the inconvenience.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down