IDictionarys Are Very Valuable



  • I found this bit of joy when I went to override a method in ASP.NET:

    protected override int ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)

    Call me behind the times, but I would have thought... uh... That the keys and values were both held in a dictionary...

    Oh well. I suppose this means something sensible, but I'll be damned if I know what it is at first glance.
     



  • Not much of a WTF.

    Keys is just a dictionary for filtering (when not databound - otherwise meaning changes). That means you can change values where keys [a=1; b=2] - multicolumn WHERE clause.
    Values updates columns with names from values.Keys with values from values.Values.

    Though I still have no idea what oldValues does... It's not documented and I don't really see what would happen when more than one row is updated...

    Example from MSDN for this method is "the real WTF":

    public override bool CanUpdate {
    get {
    return false;
    }
    }
    protected override int ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)
    {
    throw new NotSupportedException();
    }

     Yup... that surely helped :D



  • I did figure out the meaning soon after and, as you saw, MSDN was not much help. However, the MSDN example is part of a larger example which only implements Select. So, they carved it up, exceptions and all, into the individual examples...

    I'm in the middle of a project to write a "generalized" solution for managing table data with no special fields. Beware of assignments to "generalize" something, as managers will not allocate enough time to complete them, no matter what.
     


Log in to reply