So I just fixed a bug in a framework I\'m developing. The pseudo-pseudocode looks like this:
myoldObject = new MyObject { someValue = \"old value\" };
cache.Inse
A little improvement on Marks anwser when using linq:
When using Linq, fetching entities from DB will mark every object as IsDirty. I made a workaround for this, by not setting IsDirty when the value is not set; for this instance: when null. For ints, I sat the orig-value to -1, and then checked for that. This will not work, however, if the saved value is the same as the uninitialized value (null in my example).
private string _name;
[Column]
public string Name
{
get { return _name; }
set
{
if (value != _name)
{
if (_name != null)
{
IsDirty = true;
}
_name = value;
}
}
}
Could probably be improved further by setting IsDirty after initialization somehow.