how run store procedure in web api c# netcore 6

i want run a store procedure from controller in web api netcore 6 but always give me error 500 , i try multiples solution and always error 500.
I want to send 2 parameters and receive a list

this is the sp

ALTER   PROCEDURE [dbo].[listaProductoPrecio]
@Minimo int,
@Maximo int
    Select * from dbo.Productos where PrecioProducto BETWEEN @Minimo AND @Maximo

and next is the controller

        public IEnumerable<Producto> listaEntrePrecios(int minimo, int maximo)

            var parameters = new[]
                new SqlParameter("@Minimo",minimo),
                new SqlParameter("@Maximo",maximo)

            var lista = context.productos.FromSqlRaw("EXECUTE listaProductoPrecio @Minimo @Maximo", parameters).ToList();
            return lista;

i do that just for i want try a store procedure in a api, im a newbie programming, help plss

>Solution :

You are simply missing a comma:

"EXECUTE listaProductoPrecio @Minimo @Maximo"

should be

"EXECUTE listaProductoPrecio @Minimo, @Maximo"

Leave a Reply