I have the following code in which I add items to a list by foreach
this is my code:
var archivosguardados = new List<Archivos>();
foreach (var a in modelArchivo)
{
FactoryClass.ArchivoModelToArchivo(_bd, a, ref archivo);
archivosguardados.Add(archivo);
}
_bd.Archivos.AddRange(archivosguardados);
_bd.SaveChanges();
It happens that archivosguardados
after going through the foreach has two elements but these are repeated, and since modelArchivo
already verify that it is passing the list correctly.