mvc Views with Entity Framework [closed]

1

I am starting a new MVC project with Entity Framwork and I need to save information in 3 different tables, for this I have created a stored procedure. What I want to do is create a form from that procedure.

What can I do to create the form? Can you help me with an example?

    
asked by Dev Castillo 03.05.2017 в 18:57
source

1 answer

0
CREATE PROCEDURE [dbo].[GetResultsForCampaign]  
@ClientId int   
AS
BEGIN
SET NOCOUNT ON;

SELECT AgeGroup, Gender, Payout
FROM IntegrationResult
WHERE ClientId = @ClientId
END

We create a class that goes like this:

public class ResultForCampaign
{
    public string AgeGroup { get; set; }

    public string Gender { get; set; }

    public decimal Payout { get; set; }
}

And we call the stored procedure doing the following:

using(var context = new DatabaseContext())
{
        var clientIdParameter = new SqlParameter("@ClientId", 4);

        var result = context.Database
            .SqlQuery<ResultForCampaign>("GetResultsForCampaign @ClientId", clientIdParameter)
            .ToList();
}
    
answered by 03.05.2017 / 19:06
source