I working on an MVC product using Database first entity framework approach, I added a few stored procedure to the EDM, but some are returning string instead of the model type. I have deleted the model.edmx, removed the connection string from the web.config file and re- added model1.edmx file to the project, yet, some still have string as return type, I have also created a viewmodel class and use it in place of the string, yet no luck. I want to be able to add procedure to return type of the model.
Stored Procedure in Model1.Context class:
public virtual ObjectResult<string> PreLoadWorkflowType()
{
return((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<string>("PreLoadWorkflowType");
}
I want the generated stored procedure to look like this instead:
public virtual ObjectResult<PreLoadWorkflowType> PreLoadWorkflowType()
{ return((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<PreLoadWorkflowType>("PreLoadWorkflowType");
}
Stored Procedure:
USE [databsename]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[PreLoadWorkflowType]
AS
BEGIN
SET NOCOUNT ON;
select distinct workflow_type AS WorkflowType from V_ui_View where
workflow_type is not null
END
I have been adding stored procedure to the EDM file all the while, i have not experience this before, I will appreciate assistance from anyone who had experienced and resolved this.
What I have tried:
public virtual ObjectResult<PreLoadWorkflowTypeViewModel> PreLoadWorkflowType()
{ return((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<PreLoadWorkflowTypeViewModel>("PreLoadWorkflowType");
}