locked
EntitySet implementation of IList.Add

    Question

  • Why EntitySet`1 implementation of IList.Add does not raise ListChanged event:

    EntitySet<MyEntityClass> eset=...
    var lst=(IList)eset;
    lst.Add(myEntity);

    And this code raises event:

    lst.Remove(myEntity);
    Saturday, December 08, 2007 7:25 PM

All replies

  • Your problem might be caused by the fact that the EntitySet only raises the ListChanged event if it is fully loaded. To force an empty EntitySet to load, use the following code:

    Code Block

    eset.Assign(null);

     

     

    Sunday, December 09, 2007 5:08 PM
  • No. EntitySet is loaded.
    If you decompile the EntitySet via the Reflector, you will see, that there is no ListChanged event raising in the IList.Add implementation.

    Is it bug?
    Sunday, December 09, 2007 7:22 PM
  • Sorry, my bad, you're right.
    Seems like one more bug in the EntitySet implementation. The rest of the IList implementation seems to be mapped correctly to IList<T>.

    Sunday, December 09, 2007 8:24 PM