Return Result from Select Query in stored procedure to a List

前端 未结 8 2032
猫巷女王i
猫巷女王i 2021-01-01 10:10

I\'m writing a stored procedure that currently contains only a SELECT query. It will be expanded to do a number of other things, which is why it has to be a sto

8条回答
  •  遥遥无期
    2021-01-01 10:40

    I had the same question, took me ages to find a simple solution.

    Using ASP.NET MVC 5 and EF 6:

    When you add a stored procedure to your .edmx model, the result of the stored procedure will be delivered via an auto-generated object called yourStoredProcName_result.

    This _result object contains the attributes corresponding to the columns in the database that your stored procedure selected.

    The _result class can be simply converted to a list:

    yourStoredProcName_result.ToList()
    

提交回复
热议问题