Quantcast
Channel: DataSource Controls - SqlDataSource, ObjectDataSource, etc.
Viewing all articles
Browse latest Browse all 956

Call procedure in asp.net mvc5 EF6 w/o parameters

$
0
0

Hi, 

I have this procedure that I try to call:

CREATE PROCEDURE [dbo].[PipelineProcedure]
AS
SELECT p.PipelineID,max(PipelineJobStatus.CreatedTimeStamp),Client.ClientName,FCO.NameFCO,p.ProjectValueHr,p.ProjectValueMoney, p.CommentPipeline, PipelineJobStatus.CreatedTimeSTamp,p.ModifiedTimeStamp,Employee.Name,Employee.Surname, JobStatus.JobStatusName
FROM (Pipeline p LEFT OUTER JOIN PipelineJobStatus ON p.PipelineID=PipelineJobStatus.PipelineID)
INNER JOIN JobStatus ON (PipelineJobStatus.JobStatusID=JobStatus.JobStatusID)
LEFT OUTER JOIN Client ON (p.ClientID = Client.ClientID)
LEFT OUTER JOIN FCO ON (p.FCOID = FCO.FCOID) 
LEFT OUTER JOIN Employee ON (p.CreatedBy = Employee.EmployeeD)
Where PipelineJobStatus.CreatedTimeStamp in (select max(CreatedTimeStamp) from PipelineJobStatus group by PipelineID)
Group By p.PipelineID,Client.ClientName,FCO.NameFCO,p.ProjectValueHr,p.ProjectValueMoney, p.CommentPipeline, PipelineJobStatus.CreatedTimeSTamp,p.ModifiedTimeStamp,Employee.Name,Employee.Surname, JobStatus.JobStatusName

GO

in my model, I declared variable List <PipelineProcedure_Result>:

public class StatusPipelineMerge:IEntityBase{
...
SalesManagementEntities db = new SalesManagementEntities();
        public List<PipelineProcedure_Result> Procedure()
        {
            return db.PipelineProcedure().ToList();
        }
}

In my controller, I've created a variable:

StatusPipelineMerge merge = new StatusPipelineMerge();
            List<PipelineProcedure_Result> result = merge.Procedure();
            return View(result);

In my view, I referenced a model to PipelineProcedure_Result:

@using MVC.Controllers
@using DataAccess
@model IEnumerable<DataAccess.PipelineProcedure_Result>
@*@model IEnumerable <DataAccess.PipelineJobStatu>*@

@{
    ViewBag.Title = "Index";
}

@section NumberingCSS{
    @Styles.Render("~/Content/numbering-css")
}

@section NumberingJS{
    @Scripts.Render("~/bundles/numbering-js")
}<h2>Index</h2><p>
    @Html.ActionLink("Create New", "Create")</p><table id="example" class="table table-striped table-bordered"><thead><tr><th>
                @Html.DisplayNameFor(model => model.Client)</th><th>
                @Html.DisplayNameFor(model => model.CommentPipeline)</th><th>
                @Html.DisplayNameFor(model => model.CreatedBy)</th><th>
                @Html.DisplayNameFor(model => model.CreatedTimeStamp)</th><th>
                @Html.DisplayNameFor(model => model.Employee1)</th><th>
                @Html.DisplayNameFor(model => model.FCO)</th><th>
                @Html.DisplayNameFor(model => model.ModifiedTimeStamp)</th><th>
                Options</th></tr><tfoot><tr><th>
                @Html.DisplayNameFor(model => model.Client)</th><th>
                @Html.DisplayNameFor(model => model.CommentPipeline)</th><th>
                @Html.DisplayNameFor(model => model.CreatedBy)</th><th>
                @Html.DisplayNameFor(model => model.CreatedTimeStamp)</th><th>
                @Html.DisplayNameFor(model => model.Employee1)</th><th>
                @Html.DisplayNameFor(model => model.FCO)</th><th>
                @Html.DisplayNameFor(model => model.ModifiedTimeStamp)</th><th>
                Options</th></tr></tfoot><tbody>
        @foreach (var item in Model)
        {<tr><td>
                    @Html.DisplayFor(modelItem => item.ClientName)</td><td>
                    @Html.DisplayFor(modelItem => item.CommentPipeline)</td></tr>
          }</tbody></table>

I get an error, when I try to view page:

The data reader is incompatible with the specified 'SalesManagement.PipelineProcedure_Result'. A member of the type, 'Column1', does not have a corresponding column in the data reader with the same name.

My question to you: Is that for some reason because, I didnt declare parameters in my stored procedure? What shall I do?

Thanks in advance,


Viewing all articles
Browse latest Browse all 956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>