Executing Stored Procedures With EF 5

I've got an Entity Framework application and a stored procedure I imported that takes one variable of type varchar. I want to get the parameter from a text box control. The results of the stored procedure I want to set at the data source for a GridView control. However, when I do dbContext.spMyProc(txtMyField.Text) I can see with intellisense that the return type of dbContext.spMyProc(txtMyField.Text) is int. I can only assume that it's returning the number of rows in the database. How can I do dbContext.storedProc and set that equal to an IEnumerable type that I can then set as the data source for a GridView?

procedure is like

select distinct
          pdh.patientId
         ,p.Page
         ,p.Gender
         ,r.Race
from PatientDiagnosisHistory as pdh
inner join.... tables

Answers


I believe that you forgot to map the return type when you are importing the procedure.

On "Add Function Import" screen you must set the entity return or create a new complex type using the columns returned by the procedure.... see this picture of the screen

if the procedure return an entity you can use this tutorial that explain how to do that.

but if you need to create a new complex type using the columns a recommend that you look this answer for a similar question.


Need Your Help

Unit test naming best practices

unit-testing naming-conventions

What are the best practices for naming unit test classes and test methods?

Ret Failure with SDL using FASM on Win32

windows assembly return sdl fasm

I'm using SDL with FASM, and have code that's minimally like the following: