sqlapi

Execute Stored Procedure Minimal API .Net


Just started playing around with API's and trying to work out how to run a Stored Procedure. I have added this method below to my Minimal API. As far as I can tell the Stored Procedure runs but returns the first line of data over and over.

app.MapGet("/AllProducts/{LocationID}", (DataContext context, int LocationID) => context.AllLocationProducts.FromSqlRaw($"GetProducts @LocationNumber='{LocationID}'").ToListAsync());

Swagger Result

Here is the result if I run in SQL. SQL Result

Any help would be appreciated.

I have tried different sql method but same result.


Solution

  • I managed to work out the issue, my Model for the Stored Procedure wasn't correct.