在Session中存储LINQ对象:好还是坏? [英] Storing LINQ object in Session : good or bad ?

查看:67
本文介绍了在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[^]


这篇关于在Session中存储LINQ对象:好还是坏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆