I'm exporting some data from database to excel using CLOSEDXML. I need to add the corresponding objects/item to each object in the 'newModelist' IQueryable and add all the object to new List. In my case new row were added in the list using list.add method, however the old record is replaced by the next row/object. I'm not quite what would be the correct way to implement this.
var getData = _db.Database.Where(y => y.identifier == Identifier);
var newModelist = new MainModel();
var listXML= new List<listXML>();
foreach(var item in getData)
{
newModelist.col1 = item.A;
newModelist.col2 = item.B;
newModelist.col2 = item.C;
listXML.Add(newModelist);
}