2
I have a GRID (table) that when selecting an item through the ID I load the entity in a session via ajax.
public static class Sessoes
{
public static Produto Produto
{
get
{
return (Produto)HttpContext.Current.Session["Produto"];
}
set
{
HttpContext.Current.Session["Produto"] = value;
}
}
}
I wonder if it would be a bad decision to save every entity in a session? What do you think? Is there/know any disadvantage in using this practising?
Here at the company where I work is having a discussion about this... In my opinion we should save the ID and take the entity by the ID, on account of a line of code to return the entity is giving a rifle! Soon I accept the answer, let’s see if anyone else puts something!
– Trxplz0
@Correct Trxplz0. By Id, there are no problems. The important thing is not to keep as much data on a temporary and volatile object as the
Session
.– Leonel Sanches da Silva
Gypsy, about the "Sessions not out well... environment" part, you mean in-process right? Yeah, if I’m not mistaken, the Asp.NET State Service is exactly for that it’s not?
– Trxplz0
@Trxplz0 I don’t know. I’ve never used this feature. By the way, it would be good if I took a look at it.
– Leonel Sanches da Silva
Anyway, it is not good to save an entity in Session!
– Trxplz0
@Trxplz0 Exactly.
– Leonel Sanches da Silva