You could make a wrapper class and create a property. The get and set for
the property will then call the session object:
public class MyDataClass
{
public static DataSet ContractDataSet
{
get
{
return (DataSet)Session["ContractDataSet"];
}
set
{
Session["ContractDataSet"] = value;
}
}
}
You might want to do some null checks as well.
Regards,
Rick Davis
DBG Software
So this would be a static class that is maintained outside the bounds of the
page that uses it then? And I would probably put other methods/events in
this class that use the same session object?
> You could make a wrapper class and create a property. The get and set for
> the property will then call the session object:
[quoted text clipped - 51 lines]
>> >> Is there a way to refer to things in Session object without calling
>> >> Session itself?
> You could make a wrapper class and create a property.
That will not prevent the Session object from actually being called, albeit
behind the scenes - all it will do is create a completely unnecessary
additional layer of code for no benefit whatsoever...
If you want to use the Session cache, then you need to refer to it - no
getting round that...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Andy B - 30 May 2008 00:07 GMT
If all it was used for was to wrap around the Session, then it would be kind
of useless. Since the design and code of the wizard I am working on deals
with a lot of transactions between datasets and the frontend, I will need to
create other methods and properties to get the work done. Insdead of making
tons of senseless clutter inside the page, I can just make it inside a class
and then reference the class in the page code behind. Unless of course, that
isn't a good idea...
>> You could make a wrapper class and create a property.
>
[quoted text clipped - 4 lines]
> If you want to use the Session cache, then you need to refer to it - no
> getting round that...
Damien - 30 May 2008 11:49 GMT
> > You could make a wrapper class and create a property.
>
[quoted text clipped - 4 lines]
> If you want to use the Session cache, then you need to refer to it - no
> getting round that...
It ensures a) that there's no typos anywhere where the same object is
being accessed, and b) that there's agreement at all points of access
on what the data type is. (a) could be achieved by introducing a
constant, but (b) could only be achieved in that case by searching the
codebase. It's a lot nicer if you're changing a datatype to do it
inside this wrapper class and then have the compiler tell you of any
problems with that.
Damien