Hey there,

Are there any EF gurus about?
This is a further email about the issue I posted recently where pressing
escape to undo a new row on a RadGridView is throwing an exception on some
entities but not others.

I've tracked down a difference but can't seem to find anything about
SourceSets.



      public void Remove(object value)
      {
        T entity = value as T;
        if (entity != null)
        {
          this.Source.Remove(entity);
          if (this._addedEntities.Contains(entity))
          {
            this._addedEntities.Remove(entity);
            this.Source.SourceSet.Remove(entity);
          }
        }
      }


This is the code i've decompiled to see what's happening...

the line with the sourceset.remove is throwing an exception because the
sourceset is null. I guess you could say that's a bug? I mean it's checking
if _addedEntities contains the entity before it removes it, but does not
check if the SourceSet contains the entity before trying to remove it. I
don't know enough about the EntityFramework to know what a SourceSet is...
may just be an internal only structure or something else?


      int index = -1;
      if (entity.EntitySet == this)
      {
        index = this._list.IndexOf(entity);
      }
      if (index == -1)
      {
        throw new InvalidOperationException(Resource.EntitySet_EntityNotInSet);
      }


Inside the remove (second code snippit above) it checks if the entity is not
in the set and throws an InvalidOperationException.

By that, I'm taking it that the entity not being in the SourceSet is an
exceptional circumstance. Just can't figure out what that means, right now.

Feel like i'm learning to firewalk here :)

cheers,
Stephen

Reply via email to