locked
DataServiceCollection changes not firing events/bindings RRS feed

  • Question

  • Following on from this thread, I have a problem in that a DataServicesCollection I have bound to is not causing changes in the UI.

    I have a public property on a Prism ViewModel which reveals a DataServicesCollection (though this is an aside).

    In a method (elsewhere) I submit a couple of changes to the context. In fact I am adding to two tables represented by the above entity and another one. I then call SaveChanges on the context.

    The entities are quite straightforward with half a dozen properties of simple types.

    Stepping through the code of SaveChanges I find that the code in reference.cs protected virtual void OnPropertyChanged(string property) discovers that there is nothing subscribed to the event. This, I suppose, is the reason that the CollectionChanged event of the DataServicesCollection does not fire.

    If I manually call myDataServiceCollection.Load(context.Entities) the  CollectionChanged event of the DataServicesCollection does fire (and by signalling that my public property has changed I can get the UI binding to work).

    If I call the more complicated constructor of DataServiceCollection and pass in delegates for entitychanged and collectionchanged these are not called either.

    Any ideas?

    cheers

    Matt

     

    Wednesday, May 26, 2010 1:03 PM

All replies

  • Some more information in case it is useful...

    My saving code is functionally equivalent to the following

          Context.AddToTypeA(typeA);
          Context.AddToTypeB(typeB);
          Context.SaveChanges();

    Where Context is a protected property in the base class of my data services object which calls a method of another class to get the context (I do this to ensure that all parties involved get the same context via a singleton, and I have tested that they do indeed get the same context).

    In my viewmodel is code functionally equivalent to

       collection = new DataServiceCollection<TypeB>();
       collection.Load(Context.TypeB);
       collection.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(collection_CollectionChanged);

    and

      private void collection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
      {
       OnPropertyChanged("Collection");
      }
    which is never invoked
    Wednesday, May 26, 2010 4:14 PM
  • I'm not able to reproduce this issue. What version of the .NET Framework are you using?  Could you send us a repro..... email me at mike.flasko at microsoft.com

     


    Mike Flasko WCF Data Services/OData Team, Lead Program Manager
    Monday, June 14, 2010 9:20 PM
  • Not sure if I can any more - am doing something else. Might be able to in a few weeks.

    (.Net 3.5 SP1 + most recent ADO.Net Data Services refresh)

    Matt

    Tuesday, June 15, 2010 7:55 AM