I'm consuming a webservice
, which has at least 5557
records.
The problem is after consuming. I have to add the records in my database, and for that, I have to make a foreach
, which ends up hindering the performance a little, taking an average of 5 minutes.
How do I get better?
var tb_municipio_ws = _ServiceReaderClient.MunicipioListar();
if (tb_municipio_ws.Items != null || tb_municipio_ws.Item != null)
{
foreach (var item in tb_municipio_ws.Items)
{
var tbMunicipios = new TB_MUNICIPIOS
{
MUN_ID = item.MunId,
/*
....
*/
};
_context.TB_MUNICIPIOS.Add(tbMunicipios);
}
}
_context.SaveChanges();