Problem
Whenever a property in a related entity is read in code, Light Switch fires a change event on the parent, but doesn’t actually change any properties on the parent.
Solution
Just put this code at the start of all _Changed methods and you are save. The code after that will only run when the entity has really changed.
c#
|
1 2 |
if (this.Details.EntityState == EntityState.Unchanged || this.Details.EntityState == EntityState.Deleted || this.Details.EntityState == EntityState.Discarded ) return; |
vb.net
|
1 2 3 |
If Me.Details.EntityState = EntityState.Unchanged OrElse Me.Details.EntityState = EntityState.Deleted OrElse Me.Details.EntityState = EntityState.Discarded Then Return End If |
Pingback: LightSwitch Community & Content Rollup–February 2013 - Beth Massi - Sharing the goodness - Site Home - MSDN Blogs
Pingback: LightSwitch Community & Content Rollup–February 2013 | MSDN Blogs