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

关系转对象

时间:2015-01-08 21:31:45      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:

public List<MemmberInfo> GetAllMemmberInfoByDelFlag(int delFlag)
{
  string sql = "select   MemmberId,MemName,MemMobilePhone,MemAddress,MemType,MemNum,MemGender,MemDiscount,MemMoney,SubTime,MemIntegral,MemEndServerTi  me,MemBirthdaty from MemmberInfo where DelFlag=@DelFlag";
  DataTable dt = SqliteHelper.ExecuteTable(sql, new SQLiteParameter("@DelFlag", delFlag));
  List<MemmberInfo> list = new List<MemmberInfo>();
  if (dt.Rows.Count > 0)
  {
    foreach (DataRow dr in dt.Rows)
    {
      MemmberInfo mem = RowToMemmberInfo(dr);
      list.Add(mem);
    }
  }
  return list;
}

 

 

private MemmberInfo RowToMemmberInfo(DataRow dr)
{

  

MemmberInfo mem = new MemmberInfo();
mem.MemAddress = dr["MemAddress"].ToString();
mem.MemBirthdaty = Convert.ToDateTime(dr["MemBirthdaty"]);
mem.MemDiscount = Convert.ToDecimal(dr["MemDiscount"]);
mem.MemEndServerTime = Convert.ToDateTime(dr["MemEndServerTime"]);
mem.MemGender = dr["MemGender"].ToString();
mem.MemIntegral = Convert.ToInt32(dr["MemIntegral"]);
mem.MemmberId = Convert.ToInt32(dr["MemmberId"]);
mem.MemMobilePhone = dr["MemMobilePhone"].ToString();
mem.MemMoney = Convert.ToDecimal(dr["MemMoney"]);
mem.MemName = dr["MemName"].ToString();
mem.MemNum = dr["MemNum"].ToString();
mem.MemPhone = mem.MemMobilePhone;//小坑 有没有都可以
//mem.MemTpName==坑
mem.MemType = Convert.ToInt32(dr["MemType"]);
mem.SubTime = Convert.ToDateTime(dr["SubTime"]);

return mem;  

}

关系转对象

标签:

原文地址:http://www.cnblogs.com/bidianqing/p/4211841.html

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