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