You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by Ron Grabowski <ro...@yahoo.com> on 2007/01/21 20:24:19 UTC

DictionaryStrategy.cs - reader.GetName(i) vs property.PropertyName

In DictionaryStrategy.cs, shouldn't we allow for the column name to be renamed? This is what the code looks like right now:

int count = reader.FieldCount;
for (int i = 0; i < count; i++) 
{
    ResultProperty property = new ResultProperty();
    property.PropertyName = "value";
    property.ColumnIndex = i;
    property.TypeHandler = request.DataExchangeFactory.TypeHandlerFactory.GetTypeHandler(reader.GetFieldType(i));
    dictionary.Add(
        reader.GetName(i),  // always get the true column name ???
        property.GetDataBaseValue(reader));
}

Should it look something more like this:

IDictionary dictionary = (IDictionary) outObject;
if (request.CurrentResultMap != null)
{
    for (int i=0;i<request.CurrentResultMap.Properties.Count;i++)
    {
        ResultProperty property = request.CurrentResultMap.Properties[i];
        dictionary.Add(
            property.PropertyName,
            property.GetDataBaseValue(reader));
    }
}
else
{
 // original for loop
}


Re: DictionaryStrategy.cs - reader.GetName(i) vs property.PropertyName

Posted by Gilles Bayon <ib...@gmail.com>.
This code is used when a 'resultClass' attribute is specified on the
statement so the column name is the property name (Auto Mapping).

-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>