Make a query using Entity Framework and Stored Procedures

2

I have the procedure procRetornaCliente that receives the following parameters: Id, areaAuthentication, City. Mapping it to EDMX, I got a Complex Type ( procRetornaClienteModel ) with all fields mapped, but I do not know how to make a query using the Entity Framework, I already researched and every site does a different example. My structure is as follows:

using (DataBaseAdmin db = new DataBaseAdmin())
{
    int id = Session["_id"];
    String areaAtuacao = Session["_areaAtuacao"].ToString();
    String Cidade = Session["_Cidade"].ToString();
}
    
asked by anonymous 03.07.2014 / 14:45

1 answer

3

Have you ever tried something like this?

using (DataBaseAdmin db = new DataBaseAdmin())
{
    int id = Session["_id"];
    String areaAtuacao = Session["_areaAtuacao"].ToString();
    String Cidade = Session["_Cidade"].ToString();

    //retornar da procedure
    var object = db.procRetornaClienteModel(id);

    //manipular e salvar
    var cliente; // coloque aqui código pra transformar seu retorno em uma entidade cliente.
    cliente.AreaAtuacao = areaAtuacao;
    cliente.Cidade = Cidade;
    db.SaveChanges();
}

For a better answer you need to have more information about what exactly your procedure does, what its entities are, and so on. But I hope I have helped.

    
03.07.2014 / 14:59