1
Good afternoon, you guys. I am writing a consultation method and need to pass a list of positions to my Precedent to get a list of employees. I am trying to use a TVP instead of sending a string with concatenated Ids. However, I don’t know how to add the parameter.
Follow the current code (it’s not working that way):
public IList<Funcionarios> Selecionar(DataTable TVPcargo)
{
IList<Funcinarios> resultado;
TransactionOptions options = new TransactionOptions();
options.IsolationLevel = IsolationLevel.ReadCommitted;
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
{
using (Database database = new Database("stringDB"))
{
DbCommand cmd = database.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "ProcRetornaFunc";
database.AddInParameter(cmd, "@Cargo", SqlDbType.Structured, TVPcargo);
resultado = new List<Funcionarios>(database.MapRows<Funcionarios>(cmd, MapearRegistro));
}
scope.Complete();
}
return resultado;
}
Thank you!
One detail I forgot to mention is that Procedure returns the values correctly when called directly in SQL Server. The problem is that I’m not sure how to add the tvp parameter and return to the list.
– Conrado Silva