We're working on a project using ASP.NET MVC4. In one of team's meeting, came out an idea of using Session per request pattern.
I did a little search and found out some questions here in SO saying - in general - that this pattern (if may be called) it's indicated to frameworks ORM.
A little example
//GET Controller/Test
public ActionResult Test()
{
//open database connection
var model = new TestViewModel
{
Clients = _clientService.GetClients(),
Products = _productService.GetProducts()
};
//close database connection
return View(model);
}
Without session per request:
//GET Controller/Test
public ActionResult Test()
{
var model = new TestViewModel
{
Clients = _clientService.GetClients(), // Open and close database connection
Products = _productService.GetProducts() // Open and close database connection.
};
return View(model);
}
Doubts
- To contextualize, how does session per request works?
- Is it a good solution?
- What is the best way to implement it? Open the connection on web?
- Is it recommended in projects with complex queries / operations?
- Is there a possibility of giving a concurrency problem when transactions are involved?
Aucun commentaire:
Enregistrer un commentaire