Pass datatable to storedprocedure with Dapper . net core

Asked

Viewed 50 times

0

I have a proc with the following parameters

 @TabelaIdsCompras TipoTabelaIdGenerico READONLY,  
 @TabelaIdsProds TipoTabelaIdGenerico READONLY  

And I have my datatables:

DataTable tableIdsProd= new DataTable();
tableIdsProd.Columns.Add("IdGenerico");
idsSkus.ForEach(id => tableIdsProd.Rows.Add(id.ToString()));

DataTable tableIdsCompra = new DataTable();
tableIdsCompra.Columns.Add("IdGenerico");
idsCompras.ForEach(id => tableIdsCompra.Rows.Add(id.ToString()));

However I can not with Dapper pass a table type to the Procedure has no equal option with sqldbtype :

command.AddInParameter("TabelaIdsCompras", SqlDbType.Structured, tableIdsCompra);

Is there any solution to pass these datatables to proc with Dapper ?

  • Why do you want to spend one DataTable as a parameter? I ask this because maybe there is another solution to your problem.

  • So man, the "standard" of the company and exhume procs in the bank, that proc would be for verification of existing data however I can not stay stop several times in proc for performance issues, because it will be a rasable amount of data that will be checked, the idea was to assemble the datatable with the ids that I need to check in the database, ie would pass two arrays (in datatable format), and in proc I would read from this table. and I can’t do this direct verification in the code because if you change something in the way of checking the duplicates it is easier to change the file than to upload the code to the server.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.