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

IBatis一对多查询

时间:2016-05-27 20:24:05      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

namespace IBatis { public class User { public int UserId { get; set; } public string UserName { get; set; } } public class UserRight { public int UserRightId { get; set; } public int UserId { get; set; } public int RightId { get; set; } public string RightName { get; set; } } public class UserRightJoin { public int UserId { get; set; } public string UserName { get; set; } public IList UserRights { get; set; } } } 在Mapper的UserRight.xml中 在 sqlmap.config 然后是 DAO public class BaseDao { public static ISqlMapper _sqlMap = null; static BaseDao() { _sqlMap = Mapper.Instance(); } } public class UserDao : BaseDao { public IList GetList() { ISqlMapper mapper = _sqlMap; IList ListPerson = mapper.QueryForList("selectAllUserRight", null); //这个"selectAllUserRight"就是xml映射文件的Id return ListPerson; } } 最后是调用 static void Main(string[] args) { UserDao ud=new UserDao(); var lst= ud.GetList(); }

IBatis一对多查询

标签:

原文地址:http://www.cnblogs.com/zhshlimi/p/5535788.html

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