码迷,mamicode.com
首页 > 其他好文 > 详细

Mybatis将List<T> 作为参数

时间:2015-03-20 18:18:54      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

实体类文件:Map.cs与UserInfo.cs

[Serializable] 
 public class Map
{
  public string UserID { get; set; }
       public string UserGroup { get; set; }
 }

 

[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="List"> 
        select * 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();

 

Mybatis将List<T> 作为参数

标签:

原文地址:http://www.cnblogs.com/streamice/p/IbatisList.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!