New Posts New Posts RSS Feed: PropertyChanged event not firing in Distributed mode.
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

PropertyChanged event not firing in Distributed mode.

 Post Reply Post Reply
Author
BringerOD View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 27-Aug-2010
Location: USA
Posts: 35
Post Options Post Options   Quote BringerOD Quote  Post ReplyReply Direct Link To This Post Topic: PropertyChanged event not firing in Distributed mode.
    Posted: 12-May-2011 at 10:29pm

When I handled the PropertyChanged event on an entity it fires as expected when my application is connected to the database server in the App.Config.

When I switch it to use the webservice in distributed mode and comment out the connection to the database like below, the event no longer fires.   Is this by design and if so how to I trap the property changed event.

      <objectServer remoteBaseURL = "http://XXX.XXX.XXX"

                    serverPort = "80"

                    serviceName = "EntityService.svc" >

         <clientSettings  isDistributed="true" />

      </objectServer>

 

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 13-May-2011 at 4:05pm
Hi Bryan,
 
I could not reproduce your issue here.
 
In my test case PropertyChanged fires in both 2 and n-tier.
 
When you set isDistributed ="true" in the App.Config did you update the connectionString in the Web.Config file? (btw, you don't really need to comment out the connectionString in the App.Config file - setting isDistributed="true" will suffice)
 
Can you provide a simple test case (against NorthwindIB) reproducing the issue?
 
Silvio.


Edited by sbelini - 13-May-2011 at 4:07pm
Back to Top
BringerOD View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 27-Aug-2010
Location: USA
Posts: 35
Post Options Post Options   Quote BringerOD Quote  Post ReplyReply Direct Link To This Post Posted: 14-May-2011 at 11:37am
uploads/916/PropertyChangeEventTest1.zip

I uploaded a sample.

Set distributed to false.  Put a breakpoint in the Customer class on the property changed event. Edit the company name field, leave the column to trigger the property event.  The event will fire.

Set distributed to true and do the same thing.  The event will NOT fire.

  void Customer_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
      {
         if (e.PropertyName == "CompanyName")
         {
            var Test = 1;

         }
      }


Bryan Reynolds
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 16-May-2011 at 11:35am
Hi Bryan,
 
What's happening in your code is that you are setting the event handler in the entity's constructor and serialization (i.e. n-tier) does not use the constructor. (in this case you'd only see the event fired on new enitities you created in the client)
 
Also, bear in mind that even in 2-tier, if you load 1000 entities, you'd be setting 1000 event handlers. (one for each entity) That's not very efficient and I suggest you use EntityGroup.EntityPropertyChanged instead:
 
var eGroup = _entities.GetEntityGroup(typeof(Customer));
eGroup.EntityPropertyChanged += new EventHandler<EntityPropertyChangedEventArgs
(eGroup_EntityPropertyChanged);
 
...
 
void eGroup_EntityPropertyChanged(object sender, EntityPropertyChangedEventArgs e) {
  if (e.Property.Name == "CompanyName") {
    var Test = 1;
  }
}
 
Silvio.
Back to Top
BringerOD View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 27-Aug-2010
Location: USA
Posts: 35
Post Options Post Options   Quote BringerOD Quote  Post ReplyReply Direct Link To This Post Posted: 16-May-2011 at 11:43am
Makes sense. 
 
Thanks!
 
Bryan
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down