I am seeing some unexpected behavior regarding NullEntity. Is this a bug? Can NullEntities be added to lists as shown, or is that intrinsically not possible?
Thanks!
Contact contact = EntityManager.Contacts.FirstOrDefault();
User nullUser = EntityManager.GetNullEntity<User>();
try
{
// At this point, contact.Users.Count == 0
contact.Users.Add(nullUser);
}
catch (Exception e1)
{
// Excepts with "Null or pending entities cannot be modified"
- presumably because adding
// the nullUser to the list contact.Users is internally trying to set an
association key on nullUser.
// However, the nullUser is actually added to the Users list.
// contact.Users.Count is now 1
bool wtf = false;
}
// Due to some odd behavior I was
seeing elsewhere, I noticed that subsequent attempts do *not* except!
// Perhaps that is because the nullUser
is already in the list?
try
{
contact.Users.Add(nullUser);
}
catch (Exception e2)
{
// Does not except on second
attempt!
bool wtf = true;
}