View call @ controller model [closed]

1

I use EF Design and I import all my models from the bank to .EDMX .

I ask: How do I call the controllers objects I create within a View ?

I have tried to put @model up to controller and it will not and I tried to create a list of a controller object also will not.

    
asked by anonymous 06.01.2018 / 02:13

1 answer

2

Man, I think you can not pass the object to View , is that it?

//Instância para acessar o banco de dados
private ApplicationDbContext ctx = new ApplicationDbContext();

public ActionResult Details(int Id)
{

    var model = ctx.Objeto.Find(Id)
    return View(model);
} 

You put the object inside the parameter of view() and in HTML you only put the model of the object:

@model Solution.Objeto

then call the @Model.Id or other property you want to get from the object.

    
08.01.2018 / 13:33