// list rows for specific userid public List <Purchase> ListForUserId(int userId) { List <Purchase> result = new List <Purchase>(); PurchaseData dao = new PurchaseData(ConnStr); DataSet ds = dao.ListForUserId(userId); foreach (DataRow dr in ds.Tables[0].Rows) { result.Add(new Purchase { Id = Convert.ToInt32(dr["id"]), UserId = Convert.ToInt32(dr["userid"]), ProductId = Convert.ToInt32(dr["productid"]) }); } return(result); }