Chathan p

Chathan p

  • NA
  • 18
  • 1.9k

How to call a output parameter in Web API using post method

Aug 22 2019 5:21 AM
I have a stored procedure that adds a new entry to a table and OUTPUTS the `TransactionId` (as int) to `@TransactionId`.
Here I want to retrieve the output parameter from a stored procedure in Entity Framework (EDMX)
(i found several questions like this but I could not grasp because I am new in web API)
I can exec the procedure just fine to the ASP.NET backend using Postman but I can't get the OUTPUT (parameter to return). I don't know how to capture the OUTPUT in the C# post method.
For clarification, I'm trying to exec a stored procedure and capture the output using entity framework. I don't know how to capture or call the output parameter in web API to display.
 
     My API code is
[HttpPost]
public void Stock([FromBody] List<spGetNewStockCountHeader_Result> jsonvalues)
{
foreach (spGetNewStockCountHeader_Result Datastock in jsonvalues)
{
ObjectParameter TransactionId = new ObjectParameter("TransactionId", typeof(Int32));
spGetNewStockCountHeader_Result Stockobject = new spGetNewStockCountHeader_Result();
Stockobject.UserID = Datastock.UserID;
Stockobject.created = Datastock.created;
Stockobject.CompanyID = Datastock.CompanyID;
Stockobject.modified = Datastock.modified;
Stockobject.modifieduserid = Datastock.modifieduserid;
Stockobject.confirm = Datastock.confirm;
Stockobject.ShopId = Datastock.ShopId;
enqentities.spGetNewStockCountHeader(Datastock.UserID, Datastock.created,
Datastock.CompanyID, Datastock.modified, Datastock.modifieduserid, Datastock.confirm,
Datastock.ShopId, TransactionId);
}
}

Answers (2)