DataTable Slow [closed]

1

Good Afternoon, Galera

I have the routine below. I would need to streamline this routine. It takes too long to process, could anyone tell me how I could do this?

Select done in DataSet dsParam can bring more than 1 line.

                    DataTable dtEndereco = new DataTable();

                    foreach (DataRow drEnd in dsParam.Tables["Endereco"].Select(string.Format("ID = {0} AND Documento = '{1}'", drNotas["ID"].ToString(), Documento)))
                    {
                        dtEndereco.ImportRow(drEnd);

                        dtEndereco.Rows[l]["ID"] = int.Parse(ID_Ini) * -1;
                        dtEndereco.Rows[l]["Documento"] = Documento_Ini;
                        l++;
                    }
    
asked by anonymous 04.05.2017 / 19:51

1 answer

-2

try to get the expression foreach, something like this:

    ...    

DataSet dsParam;
DataTable dt = dsParam.Tables["Endereco"];
DataRow[] rows;
string  expression = string.Format("ID = {0} AND Documento = '{1}'", drNotas["ID"].ToString(), Documento);

rows = table.Select(expression);
foreach (DataRow drEnd in rows)
{
   dtEndereco.ImportRow(drEnd);
   dtEndereco.Rows[l]["ID"] = int.Parse(ID_Ini) * -1;
   dtEndereco.Rows[l]["Documento"] = Documento_Ini;
   l++;
 }
    
04.05.2017 / 20:09