Showing posts with label followingi. Show all posts
Showing posts with label followingi. Show all posts

Wednesday, March 28, 2012

string, int and session

hey all,
can someone please tell me if there's a big difference among the following:
i want to store a string and an int in session.
is it better to store it like:
1. delimited string (i.e. session["test"]="test1" + ";" + 1
2. in an array
3. or 2 separate sessions
how would each one rate?
thanks,
rodcharIf they are not related, then I would store them in seperate session
variables.
If they're related...lets say you want to store the
EmpID (int) and EmployeeLoginName (string), I would create a mini wrapper
object.
[Serializable]
public class EmployeeLoginInfo
{
private int _empID = 0;
private string _employeeLoginName = string.Empty;
public EmployeeLoginInfo( int empID , string employeeLoginName )
{
_empID = empID;
_employeeLoginName = employeeLoginName;
}
public int EmpID { { return _empID;}}
public string EmployeeLoginName { get { return _employeeLoginName;}}
}
and then I would session that mini object.
Delimited String << Heck No
Array << Heck No
That's my vote.
To me, using the mini object means I only have to pay the casting price
once.
And my code make more sense, because I don't have a bunch of disjoint
properties flying all over the place.
You can check this blog entry as well:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!151.entry
"rodchar" <rodchar@.discussions.microsoft.com> wrote in message
news:74A6AE05-25B3-4CF5-8150-3E312CDFE6AB@.microsoft.com...
> hey all,
> can someone please tell me if there's a big difference among the
> following:
> i want to store a string and an int in session.
> is it better to store it like:
> 1. delimited string (i.e. session["test"]="test1" + ";" + 1
> 2. in an array
> 3. or 2 separate sessions
> how would each one rate?
> thanks,
> rodchar
>
"sloan" <sloan@.ipass.net> wrote in message
news:OOIA6HQgIHA.4164@.TK2MSFTNGP05.phx.gbl...

> [Serializable]
Not necessary if the class to be stored in Session contains only primitive
datatypes:
http://safari.oreilly.com/059600117...p-CHP-21-SECT-6

> Delimited String << Heck No
Agreed.

> Array << Heck No
Probably not, though generics are usually OK to store in Session...
Mark Rae
ASP.NET MVP
http://www.markrae.net
should the mini object be nested in a class or would it be better in a
separate file?
"sloan" wrote:

> If they are not related, then I would store them in seperate session
> variables.
> If they're related...lets say you want to store the
> EmpID (int) and EmployeeLoginName (string), I would create a mini wrapper
> object.
> [Serializable]
> public class EmployeeLoginInfo
> {
> private int _empID = 0;
> private string _employeeLoginName = string.Empty;
> public EmployeeLoginInfo( int empID , string employeeLoginName )
> {
> _empID = empID;
> _employeeLoginName = employeeLoginName;
> }
> public int EmpID { { return _empID;}}
> public string EmployeeLoginName { get { return _employeeLoginName;}}
> }
>
> and then I would session that mini object.
>
> Delimited String << Heck No
> Array << Heck No
>
> That's my vote.
>
> To me, using the mini object means I only have to pay the casting price
> once.
> And my code make more sense, because I don't have a bunch of disjoint
> properties flying all over the place.
> You can check this blog entry as well:
> http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!151.entry
>
> "rodchar" <rodchar@.discussions.microsoft.com> wrote in message
> news:74A6AE05-25B3-4CF5-8150-3E312CDFE6AB@.microsoft.com...
>
>
"rodchar" <rodchar@.discussions.microsoft.com> wrote in message
news:322B0134-B070-4C18-A041-F2718BB1E4B7@.microsoft.com...

> should the mini object be nested in a class
The (mini) object *is* a class...

> or would it be better in a separate file?
Totally irrelevant to the compiler...
Mark Rae
ASP.NET MVP
http://www.markrae.net
thanks for the help everyone,
rod.
"rodchar" wrote:

> hey all,
> can someone please tell me if there's a big difference among the following
:
> i want to store a string and an int in session.
> is it better to store it like:
> 1. delimited string (i.e. session["test"]="test1" + ";" + 1
> 2. in an array
> 3. or 2 separate sessions
> how would each one rate?
> thanks,
> rodchar
>