views:

532

answers:

1

I have this problem, I'm using Castle ActiveRecord and when I update I verify changes in the object in the OnFlushDirty event.

However, when I access to the previouState["MyProperty"], it turns to be null and I can't get the old value.

Do you know why?

this is the code;

    protected override bool OnFlushDirty(object id, System.Collections.IDictionary previousState, System.Collections.IDictionary currentState, NHibernate.Type.IType[] types)
    {
        StringBuilder errors = new StringBuilder();

        if (this._bankCode <= 0)
            errors.Append("Bank code is invalid" + Environment.NewLine);

        if (string.IsNullOrEmpty(this._name) || this._name.Trim().Length == 0)
            errors.Append("Name is invalid" + Environment.NewLine);

        //previousState["EnterpriseCode"] is always null
        if (previousState["EnterpriseCode"] != currentState["EnterpriseCode"])
        {
            if (this._enterpriseCode == 0)
                errors.Append("Enterprise code is invalid" + Environment.NewLine);
            else 

         ...
+1  A: 

I finally made it, it happens that in hibernate you must use merge() to make that hibernate "loads" the previuos data of the detached object, in Castle the equivalent is the SaveCopy() method .

nmiranda