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
>> 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.ToListAsync();
- return await _context.output.FromSqlRaw(StoredProc).ToListAsync();
- }
Edward MahoneyPosted Mar 11, 2021, 11:09 PM
Rijwan AnsariPosted Mar 11, 2021, 5:43 PM
Edward MahoneyPosted Mar 11, 2021, 4:44 PM
Kiran MohantyPosted Mar 11, 2021, 7:01 AM