I have a scenario where the user can select check boxes to select multiple records which need to be processed on a separate page. I have decided to use Session to store this data. The Session mode will be “In proc”.
I wanted to know which is the most lightweight collection/generic/object to store say 30-40 IDs ( most probably Guids/unique Identifiers ) in the session?.
Any alternate approaches/design patterns are also welcome.
If the list of possible records is a closed list you can use an enum as a bit field.
This way you can store up to 64 boolean values in a single long.
If, on the other hand you don’t have a closed list of possible values, than an array is the lightest collection there is, as most other collections are simply extensions of an array.
However, are you absolutely sure you have to use GUIDs? GUIDs are heavy and cumbersome.
The only use case you must use them is when you have data coming from multiple sources and you have to retain the IDs as they come.
I’d consider switching to int or long if it’s possible.