Skip to content Skip to sidebar Skip to footer

Calling A Stored Procedure (mvc4)

(Using MVC4 VB EF4 MSSQL Razor) I created a Stored Procedure in the MS SQL 2008 database. Then I've added that SP into the Entity Framework model (you do not see it after opening t

Solution 1:

A standard genereated list view starts with:

@ModelType Mvc4App2.[classname]

It took me a while to understand the error message correctly. you need to change that line into:

@ModelType IEnumerable(Of Mvc4App2.[name of the complextype])

I also changed the controller code a little:

Dim context AsNew [Name of the EF model]
Dim ResultAs List(Of [name of the complex type])
Result= context.ExecuteStoreQuery(Of [name of complex type])_
               ("[name of the stored procedure @p0", "[parameter 0]").ToList
ReturnView(Result)       
EndFunction

Post a Comment for "Calling A Stored Procedure (mvc4)"