I found your article below excellent. Great job.
https://www.c-sharpcorner.com/article/apiasp-net-core-web-api-entity-framewor-call-stored-procedure-part-ii/
My question is how do I get a non list JSON response returned. The person consuming the json wants a dictionary, not a list. My stored proc returns one row so no list is needed.
So from your example I want
- {
- "appointmentId": 2,
- "returnCode": 1,
- "submittedTime": "2020-12-06T15:19:10.87"
- }
not this:
- [
- {
- "appointmentId": 2,
- "returnCode": 1,
- "submittedTime": "2020-12-06T15:19:10.87"
- }
- ]
- public async Task<ActionResult<IEnumerable<output>>> Getoutput(Input input)
- {
- string StoredProc = "exec CreateAppointment " +
- "@ClinicID = " + input.ClinicId + "," +
- "@AppointmentDate = '" + input.AppointmentDate + "'," +
- "@FirstName= '" + input.FirstName + "'," +
- "@LastName= '" + input.LastName + "'," +
- "@PatientID= " + input.PatientId + "," +
- "@AppointmentStartTime= '" + input.AppointmentStartTime + "'," +
- "@AppointmentEndTime= '" + input.AppointmentEndTime + "'";
-
- return await _context.output.FromSqlRaw(StoredProc).ToListAsync();
- }