3
I’m consuming a webservice
, that has at least 5557
records.
The problem is after consuming. I have to add in my database the records, and for that, I have to do a foreach
, what ends up disturbing a little the performance, taking on average 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();
There’s not much to do there. You can probably do something at
MunicipioListar
.– Maniero
That’s what I thought, @mustache, but I can’t touch that method.
– Leonardo