在Session中存储LINQ对象:好还是坏?

在Session中存储LINQ对象:好还是坏?

问题描述:

我正在使用LINQ to SQL从数据库中获取数据。我在Session中存储LINQ对象,以便稍后在进程中使用它。在Page_Load事件期间获取对象并将其存储在Session变量中,并在其他处理期间重用它。处理完成后,我将Session变量重置为null。我实际上并没有更新这个对象。



I am using LINQ to SQL to get data from database. I am storing LINQ object in Session to use it later in the process. Get the object during Page_Load event and store it in Session variable and reuse it during other processing. I am resetting Session variable to null after processing finish. I am not actually updating this object.

DAL.BuilderMaster objBM = (DAL.BuilderMaster)Session["selectedPOBM"];





保持Session中的LINQ对象重用是一个好主意吗?

我应该创建具有与LINQ类相同属性的单独DTO类来保存LINQ对象的值并将其存储在Session中吗?



Is it a good idea to keep LINQ object in Session to reuse ?
Should I create separate DTO class with same properties as LINQ class to hold values of LINQ object and store that in Session ?

Refer这个讨论



are-linq-to-sql-objects-serializable-for-session-state [ ^ ]
Refer this discussion

are-linq-to-sql-objects-serializable-for-session-state[^]