类文件Map.cs
[Serializable] public class Map { public string UserID { get; set; } public string UserGroup { get; set; } }
类文件UserInfo.cs
[Serializable] public class UserInfo { public string UserID { get; set; } public string CardWord { get; set; } public string UserName { get; set; } public string PassWord { get; set; } public string UserPicture { get; set; } public string UserMail { get; set; } public DateTime RegTime { get; set; } public string UserStatus { get; set; } }
xml文件中的配置,表名userinfo
<!--省略非必要代码--> <resultMaps> <resultMap id="SelectAllUser" class="UserInfo"> <result property="UserID" column="ID"/> <result property="CardWord" column="Card_Word"/> <result property="UserName" column="User_Name"/> <result property="PassWord" column="Pass_Word"/> <result property="UserPicture" column="User_Picture"/> <result property="UserMail" column="User_Mail"/> <result property="RegTime" column="Reg_Time"/> <result property="UserStatus" column="User_Status"/> </resultMap> </resultMaps> <!--省略非必要代码--> <statements> <!--获取好友信息--> <select id="GetAllUserByID" resultMap="SelectAllUser" parameterClass="System.Collections.Generic.List"> <![CDATA[select ID,Card_Word,User_Name,Pass_Word,User_Picture,User_Mail,Reg_Time,User_Status from userinfo where ID in <iterate conjunction="," open="(" close=")"> #[].UserID# </iterate> ]]> </select> </statements>
使用
List<Map> hashTable = new List<Map>(); List<Userinfo> userList = null; userList = mapper.QueryForList<UserInfo>("GetAllUserByID", hashTable).ToList();
错误提示:
- The error occurred while loading SqlMap.
- loading select tag
- The error occurred in
- Check the GetAllUserByID.
各位,有何见解。。。
<select id="GetAllUserByID" resultMap="SelectAllUser" parameterClass="List"> select * from userinfo where ID in <iterate conjunction="," open="(" close=")"> #[].UserID# </iterate> </select>
搞定!!!
首先,我没这样用过;
再者,你可以用exec(@sql)的方式实现。
刚看了看Ibatis.net的帮助文档,单纯作为参数方面,List只支持System.ArrayList与System.Hashtable,看来只能变通方法了
@Smlusm: 呵呵,那就换实现思路了。
@幻天芒:你的那个算是拼字符串吧,学习了,
_(_)_ wWWWw @@@@ (_)@(_) vVVVv _ @@@@ (___) @@()@@ wWWWw (_)\ (___) _(_)_ @@()@@ Y @@@@ (___) `|/ Y (_)@(_) @@@@ \|/ / Y \| \|/ /(_) \| |/ \ | \ |/ | /\ | / \|/ |/ \| |/// \\|/// \\\\|//\\|///\|/// \\\|// \\|// ^^^^^^ 百 ^^^^^^^^^^^^^ 花 ^^^^^^^^^^^^^^^ 园 ^^^^^
兄弟如果累了.
看看http://www.cnblogs.com/humble/p/3320804.html