Storing large collections and tables

Some design considerations I would mention are

1. Storing a datatable or dataset anywhere is always a bad idea.
These classes maintain history and a ton of additional data
Best practice is to create a class for a unit of data and store a list of objects of that class
If the query is a simple one or the data is large, querying the DB again is preferable to serializing/storing/deserializing in session/viewstate/cache.

2. showModalDialog has an option to pass arguments – even a collection – from the javascript itself.
http://msdn.microsoft.com/en-us/library/ms536759(VS.85).aspx
No need to ever store or come to the backend
This can be used instead of querying the DB again

3. Viewstate is an even more dangerous place to store heavy objects than session
The network is burdened with MBs of traffic and both the browser and server are burdened with creating and storing the object
Viewstate is specifically for small page-specific data (like global variables required across postbacks)

The only place where large collections and tables can be stored are - Application, cache and static variables.
These are not user/session-specific and require specifically written properties to be used safely.

Comments