Skip to content
Advertisement

Executing a StoredProcedure in Dotnetcore3.1

I created a Stored Procedure by Selecting values from 2 different tables.

Now the problem I have is to execute and read the result data from my dotnetcore 3.1 code.

  1. I am not sure if the code I have written is correct. I am using IQueryable<AppUser> but, The SP contains a mix of AppUser and CourseMarks. So can I represent the result ?

  2. How to convert the result of IQueryable to a JSON format ?

Can someone please help me out sort this. I have been stuck in this issue for awhile now.

SQL – SP

Advertisement

Answer

You will have to create a special class for your sp result, it should include ALL data properties that are selected in your sp

All properties in this class should be the same name and type as it is in your stored procedure

Add SpPlayerResult to db context and run this code

I don’t know why you need convert it to json, since .net will do everything automatically, but you can use standard net serializer System.Text.Json

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement