IsDirty: base.IsDirty vs. this.IsDirty
IsDirty: base.IsDirty vs. this.IsDirtyOld forum URL: forums.lhotka.net/forums/t/7418.aspx
MadGerbil posted on Friday, August 07, 2009I know a developer who wrote the following code:
protected override void DataPortal_Update()
public override bool IsDirty
return base.IsDirty || _childCollection.IsDirty
When stepping through the code in the DataPortal_Update the base.IsDirty will show a value of 'true' but still skips the code contained in the if statement.
This tells me some type of error is being generated - I tried to try/catch the error but couldn't do it.
The way to correct the problem is to change the code in the DataPortal_Update from 'base.IsDirty' to 'this.IsDirty'.
The reason for this post is I want to understand WHY base.IsDirty is wrong and this.IsDirty is correct.
RockfordLhotka replied on Friday, August 07, 2009
I don't know - that sounds very odd. If it were generating an exception it would exit the method right away, not just skip that block.
Are you sure base.IsDirty is returning true? Maybe the object hasn't changed, and only some child object has changed? (that'd make base.IsDirty different from this.IsDirty)
Copyright (c) Marimer LLC