How can I assign the results of a cursor
to a List
using SQL Server
and Visual Studio
?
The cursor is in a stored procedure, which must be called from the Controller:
Stored Procedure
CREATE PROCEDURE Lista_municipios
@MunicipiosCursor CURSOR VARYING OUTPUT
AS
SET NOCOUNT ON;
SET @MunicipiosCursor = CURSOR
FORWARD_ONLY STATIC FOR
select m.id_municipio,
m.ca_municipio
from Municipio m
OPEN @MunicipiosCursor;
Controller
private InvestigacionEntities db = new InvestigacionEntities();
// GET api/Municipios
public IEnumerable<Municipio> GetMunicipios()
{
//var test = db.Lista_municipios;
return db.Lista_municipios.AsEnumerable();
}