Print Page | Close Window

ArgumentNullException in EntityManager Saved Event

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1883
Printed Date: 08-May-2024 at 12:17pm


Topic: ArgumentNullException in EntityManager Saved Event
Posted By: sebma
Subject: ArgumentNullException in EntityManager Saved Event
Date 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;
            ...
        }
 
 
 



Replies:
Posted By: ting
Date 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.



Print Page | Close Window