<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Entity.OnPropertyChanged not called</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Entity.OnPropertyChanged not called</description>
  <pubDate>Wed, 13 May 2026 05:42:42 -700</pubDate>
  <lastBuildDate>Thu, 07 Jun 2012 14:21:24 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=3307</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Entity.OnPropertyChanged not called : If you can&amp;#039;t upgrade to the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=13794#13794</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=613" rel="nofollow">stephenmcd1</a><br /><strong>Subject:</strong> 3307<br /><strong>Posted:</strong> 07-Jun-2012 at 2:21pm<br /><br />If you can't upgrade to the latest version, you can use a hack similar to the one we needed to have until we were able to upgrade. &nbsp;I made a helper method that will attach a dummy event handler which will cause the OnPropertyChanged method to be called like normal. &nbsp;Here is some sample code:<table width="99%"><tr><td><pre class="BBcode">&nbsp; &nbsp; &nbsp; &nbsp; #region Property Changed Helper<div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;summary&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// Whether we've attached the handler to this instance.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;/summary&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; private bool _propertyChangeEventHandlerAdded;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;summary&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// An instance of &lt;see cref="PropertyChangedEventHandler"/&gt; that we can use for</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// all instances as a dummy handler.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;/summary&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; private static readonly PropertyChangedEventHandler _cachedHandler = delegate { };</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;summary&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// Ensures that &lt;see cref="Entity.OnPropertyChanged"/&gt; will be fired when properties change.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;/summary&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;remarks&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// To ensure the method gets called, we need to attach a dummy event handler to&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;see cref="Entity.PropertyChanged"/&gt; - otherwise, DevForce won't even call the</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// method.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;/remarks&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; private void EnsureOnPropertyChangedFires()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (_propertyChangeEventHandlerAdded)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PropertyChanged += _cachedHandler;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _propertyChangeEventHandlerAdded = true;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; #endregion</pre></td></tr></table></div></div><div><br></div><div>I put that code into the base class that all our entities derive from. &nbsp;Then when I wanted OnPropertyChanged to get fired, I called EnsureOnPropertyChangedFires() (and it's safe to call that method multiple times). &nbsp;We had the method call in a couple of different places because there are times when we actually didn't want OnPropertyChanged to be called. &nbsp;But to keep things simple, you could probably put that call in the entity's constructor maybe.</div>]]>
   </description>
   <pubDate>Thu, 07 Jun 2012 14:21:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=13794#13794</guid>
  </item> 
  <item>
   <title>Entity.OnPropertyChanged not called : Hi Von,We don&amp;#039;t normally...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=13792#13792</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3307<br /><strong>Posted:</strong> 07-Jun-2012 at 1:01pm<br /><br />Hi Von,<div><br></div><div>We don't normally provide a hot fix patch to an older version. You can either upgrade to our latest 6.1.7.1 which can be found in our website, or to 6.1.5. I will PM you the link to download this.</div>]]>
   </description>
   <pubDate>Thu, 07 Jun 2012 13:01:47 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=13792#13792</guid>
  </item> 
  <item>
   <title>Entity.OnPropertyChanged not called : Hi,We&amp;#039;re still using Devforce...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=13777#13777</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1228" rel="nofollow">Vonzkie</a><br /><strong>Subject:</strong> 3307<br /><strong>Posted:</strong> 06-Jun-2012 at 8:19pm<br /><br />Hi,&nbsp;<div><br></div><div>We're still using Devforce 6.1.4 and we experienced the same problem, can you provide us a Hotfix Patch?&nbsp;</div><div><br></div><div>Thanks,</div><div>Von</div>]]>
   </description>
   <pubDate>Wed, 06 Jun 2012 20:19:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=13777#13777</guid>
  </item> 
  <item>
   <title>Entity.OnPropertyChanged not called : We are still on 6.1.3.1 so that&amp;#039;s...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=12865#12865</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=613" rel="nofollow">stephenmcd1</a><br /><strong>Subject:</strong> 3307<br /><strong>Posted:</strong> 29-Feb-2012 at 4:51pm<br /><br />We are still on 6.1.3.1 so that's probably why we aren't seeing this behavior. &nbsp;The test you provide is exactly the behavior I was expecting (but not seeing). &nbsp;Thanks for looking into it!]]>
   </description>
   <pubDate>Wed, 29 Feb 2012 16:51:54 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=12865#12865</guid>
  </item> 
  <item>
   <title>Entity.OnPropertyChanged not called : Hi stephenmcd1,What version are...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=12863#12863</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3307<br /><strong>Posted:</strong> 29-Feb-2012 at 12:22pm<br /><br />Hi stephenmcd1,<div><br></div><div>What version are you using?</div><div><br></div><div>I believe this issue has been fixed as of 6.1.5. Can you confirm that we're talking about the same behavior here? Below is my test code.</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>&nbsp;public partial class Employee {</div><div><br></div><div>&nbsp; &nbsp; protected override void OnPropertyChanged(PropertyChangedEventArgs e) {</div><div>&nbsp; &nbsp; &nbsp; if (e.PropertyName == "Country" &amp;&amp; this.Country == "Country") {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; this.Country = "Narnia";</div><div>&nbsp; &nbsp; &nbsp; }</div></div><div>&nbsp; &nbsp; }</div><div>}</div><div><br></div><div>var emp = mgr.CreateEntity&lt;Employee&gt;();</div><div>emp.Country = "Country";</div><div>Assert.IsTrue(emp.Country == "Narnia");</div><div></pre></td></tr></table></div><div><br></div><div><br></div>]]>
   </description>
   <pubDate>Wed, 29 Feb 2012 12:22:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=12863#12863</guid>
  </item> 
  <item>
   <title>Entity.OnPropertyChanged not called : In our entities, we often override...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=12851#12851</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=613" rel="nofollow">stephenmcd1</a><br /><strong>Subject:</strong> 3307<br /><strong>Posted:</strong> 28-Feb-2012 at 6:26pm<br /><br />In our entities, we often override Entity.OnPropertyChanged to execute logic when a property changes. &nbsp;After a lot of debugging, I just found out that OnPropertyChanged does not get called if there are not any subscribers to the Entity.PropertyChanged event. &nbsp;I can understand the rational behind this - some kind of optimization I suppose. &nbsp;But in our case, we always want OnPropertyChanged to be fired - even if nobody external is watching the entity for changes, the entity itself might be waiting for property changes.<div><br></div><div>As a hack, I've updated our entities to attach a dummy handler to PropertyChanged when they are first created and that seems to fix the problem.....but it doesn't feel like a very nice hack. &nbsp;Is there a reason that EntityAspect.FirePropertyChanged short-circuits if there are no subscribers? &nbsp;It doesn't seem like it'd be that much of an overhead and it seems like non-obvious behavior to me.</div>]]>
   </description>
   <pubDate>Tue, 28 Feb 2012 18:26:58 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3307&amp;PID=12851#12851</guid>
  </item> 
 </channel>
</rss>