How to return a list by passing a DVT as a parameter

1

Good afternoon, guys. I am writing a query method and need to pass a list of charges to my procedure to get a list of employees. I'm trying to use a TVP instead of sending a string with concatenated Ids. However, I do not know how to add the parameter.

Follow the current code (not working this 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!

    
asked by anonymous 10.01.2017 / 18:32

0 answers