Quote from MSDN:
============================================================================
==============
public class Dictionary<TKey,TValue> : IDictionary<TKey,TValue>,
ICollection<KeyValuePair<TKey,TValue>>, 
        IEnumerable<KeyValuePair<TKey,TValue>>, IDictionary, ICollection,
IEnumerable, 
        ISerializable, IDeserializationCallback
============================================================================
==============
The Dictionary<> class does not implement the IList interface.

May be you can convert your Dictionary<String,String> to an
List<KeyValuePair<String,String>> before calling " UpdateTestLCID":

List<KeyValuePair<String,String>>  list = new
List(testObject.Names); //each item in the list is an instance of
KeyValuePair<String,String>
SqlMapper.Update("UpdateTestLCID", list);

But I DON’T think this will solve your business requirement.

Quote from your previous mail:
============================================================================
==============
<select id="SelectDescLCID" parameterClass="string" resultmap="?????">
   SELECT LCID as Key, Descr as Value
   FROM ITEMDESC
   WHERE itemId=#value#
</select>
============================================================================
==============
I assume that each LC pair is stored as a database record.
So the batch of update statements generated by IBatis does not handle those
new or deleted LC pairs.

As the record size in the "ITEMDESC" table is so small, may be you can
delete all existing records for an "ItemId" and let the IBatis generate a
batch of INSERT statements instead.

-----邮件原件-----
发件人: Andrea Tassinari [mailto:[EMAIL PROTECTED] 
发送时间: 2008年1月16日 23:16
收件人: [email protected]
主题: Re: Selecting a key value pair 

At 09.34 11/01/2008, Andrea Tassinari wrote:

>At 17.04 10/01/2008, smartkid wrote:
>
>>Use "System.Collections.IDictionary" as the resultClass for
"SelectDescLCID"
>
>Nahhh, is that so simple and straightforward? I cannot believe it! I should
have tried this before. Let me give it a chance :-)
>
>thanks.

Ok, it is *not* so striaghtforward. Current SVN version of the datamapper
exposes a new set of QueryforDictionary<T,V> methods that help a lot getting
a Dictionary<string,string> from a mapped statement.

So, in order to get an object with a Dictionary<string,string> property the
best solution I found is to run 2 query statements. RIP for the lazy
loading... it is acceptable.

Now I'm facing the reverse problem: unroll the dictionary into an update
statement. It would be better to unroll the dictionary within a mapped sql
statement in the SqlMap file, somethig like this (Names is my
Dictionary<string,string> property for the class Test)

<update id="UpdateTestLCID" parameterClass="Test">
  <iterate conjunction=";" open="" close="" property="Names">
      UPDATE testLCID
        SET NOME='$Names[].Key$'
      WHERE refid=1
      AND LCID='$Names[].Value$'
  </iterate>
</update>

this does not work, the mapper complains about Names is not a list or an
array (which, I understand, it is true);

any idea?

Thanks
Andrea

public sealed class Test
{
        private int? _id;
        private IDictionary<string,string> _names;
        
        public Test()
        {
                _id     = null;
                _names = new Dictionary<string,string>();
        
        }
        
        public int? Id
        {
                get { return _id; }
                set { _id = value; }
        }
        public IDictionary<string,string> Names
        {
                get { return _nomi; }
                set     { _nomi = value; }
        }
}


>Andrea 
>
>
>
>-- 
>No virus found in this incoming message.
>Checked by AVG Free Edition. 
>Version: 7.5.516 / Virus Database: 269.19.0/1218 - Release Date: 1/10/2008
1:32 PM
>
>
>
>
>-- 
>No virus found in this incoming message.
>Checked by AVG Free Edition. 
>Version: 7.5.516 / Virus Database: 269.19.0/1218 - Release Date: 10/01/2008
13.32

Reply via email to