Search code examples
c#entity-framework-4wcf-ria-services

How to raise property changed event from outside of Entity?


Entities already implement the PropertyChanged. If properties are changed, PropertyChanged will be fired.
What I want now is: I want to fire PropertyChanged event in code even the value actually not changed (for binding purpose). I want to do something like from outside of the entity:

MyEntity.RaisedPropertyChanged("myProperty");

Also know that Entities have OnPropertyChanged method, but it is protected, only available inside the class or its subclass.

How to implement this request?


Solution

  • Someone else might point out a why you shouldn't have to do this, but one simple thing is to add a public method that relays to the protected method.

    public partial class MyEntity
    {    
        public void RaisePropertyChanged(string propertyName)
        {
           this.RaisedPropertyChanged(propertyName);
        }
    }