I have the following code in c#:
List<Usuario> ret = new List<Usuario>();
UsuarioRepositorio repositorio = new UsuarioRepositorio();
var dtos = repositorio.Seleccionar();
foreach(dtos)
{
ret.Add(dtos);
}
return ret;
As you can see, I have a List called ret
and dtos is a List DTO that receives the values from the Seleccionar()
. But I would like to know how to traverse or map data to store it in ret, and then return it.
If you want to map the properties of a data to a user and then add it to your list of users:
using System.Collections.Generic
although if it is only for mapping I recommend you look at AutoMapper
Cheers,
Thank you very much everyone, your comments were very helpful, it is already resolved:
What you have to put in it
foreach
is an element to handle during the iteration.For that matter, every time it
foreach
finds an element indtos
it, it will "select" that element and reference it in thevar
"data" variable and thus treat it within that block.