Try either changing your statement to:

SELECT VALUE AS CODE, DESCRIPTION FROM CODEMAP

or specifiying the "VALUE" property as the keyProperty parameter like this:

QueryForDictionary<int,string>("TestQueryForDictionary", null, "VALUE")

On May 7, 2010, at 3:55 AM, tech fan wrote:

> Hi, thanks for the info.
>  
> The table contains just 2 columns, 'value': int, 'description': varchar.
>  
> Here is the map:
>  
> <?xml version="1.0" encoding="utf-8" ?>
> <sqlMap namespace="TestParameters" xmlns="http://ibatis.apache.org/mapping"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>   <statements>
>   
>     <select id="TestQueryForDictionary">
>       SELECT VALUE, DESCRIPTION FROM CODEMAP
>     </select>
>   
>   </statements>
>   </sqlMap>
> 
> Here is the code:
>         [Test]
>         public void Test_QueryForDictionary()
>         {
>             IDictionary<int, string> r = _db.QueryForDictionary<int, 
> string>("TestQueryForDictionary", null, "CODE");
>             Assert.That(r.Count, Is.EqualTo(2));
>         }
> I got an error like this:
> IBatisNet.Common.Exceptions.ProbeException : There is no Get member named 
> 'CODE' in class 'Object[]'
> I guess I need to put resultClass parameter or something in the map, but I 
> don't want to create a type for that :(
>  
> Regards,
> tc.
> On Thu, May 6, 2010 at 11:02 PM, Dave Curylo <cury...@asme.org> wrote:
> Can you include a snippet of your code?  QueryForDictionary should do what 
> you described without the need to create a new class.
> 
> From: tech fan
> Sent: Thursday, May 06, 2010 4:26 PM
> To: user-cs@ibatis.apache.org
> Subject: QueryForDictionary<K,V>, do I really have to creae a class for this?
> 
> Hi,
>  
> I have a table with just a integer as pk and a string as description. I need 
> to retrieve all data into a IDictionary<int, string>(this table is human 
> mantained), but I really don't want to creaet a class just for this simple 
> task. But it seems QueryForDictionary converts the result to an object before 
> I can access it. Is there any solution to this? I tried to use set the result 
> class to System.Collections.Generic.Dictionary`2[System.UInt16,System.String] 
> with no luck.
>  
> Thanks a have a nice day.
> tc.
> 

Reply via email to