Im trying to add data in a dataset into a List. This is my function in C#
public List<ProductsDAL> GetAllProducts(string sqlQuery)
{
DataSet dsinsert = GetDataSet(sqlQuery, "tblProducts");
List<ProductsDAL> bPList = new List<ProductsDAL>();
ProductsDALforeach (DataRow item in dsinsert.Tables[0].Rows)
{
this.Product_ID = item["Product_ID"].ToString();
this.ProductDescr= item["ProductDescr"].ToString();
bPList.Add(this);
}
return bPList;
}
The result in the dataset is like
column1 - colum2
A 1
B 2
C 3
D 4
But I think the result in the list is:
column1 - colum2
D 1
D 1
D 1
D 1
When I insert this set of data into another database I only get this:
column1 - colum2
D 1
What am I doing wrong in my function ?