I have a web application with the repository layer and the WebUI layer.
Basically i fill some grids with data that i get from this repository dll. Actually im doing like this:
private DemoRepository _demoRepository;
public DemoController()
{
_demoRepository = new DemoRepository();
}
public ActionResult Demonstration()
{
return View(_demoRepository.GetAll());
}
My question is, actually i dont need to create an object everytime so i could make the DemoRepository static and call directly in the ActionResult method:
public ActionResult Demonstration()
{
return View(DemoRepository.GetAll());
}
But otherwise i know that its not a good practice to use static variables in web application, but in this case that im executing a method to get some data, is it correct?