I want to replace the hard coded data in the code below with data from my database that I\'ve created using the Code First approach.
However, I literally have no ide
You can try using following way
public Product GetChartData()
{
Product objproduct = new Product();
List yr = null;
List sal = null;
List pur = null;
yr = db.tblCharts.Select(y => y.Years).ToList();
sal = db.tblCharts.Select(y => y.Sale).ToList();
pur = db.tblCharts.Select(y => y.Purchase).ToList();
objproduct.Year = string.Join(",", yr);
objproduct.Sale = string.Join(",", sal);
objproduct.Purchase = string.Join(",", pur);
return objproduct;
}
I hope that will resolve your problem.