A
Andy B
Is there a way to refer to things in Session object without calling Session
itself?
itself?
Andy B said:I am trying to avoid having to do something like this every time I want an
object from Session:
((DataSet)Session["ContractDataSet"]).Tables["..."]...;
or:
DataSet ContractDataSet = (DataSet)Session["ContractDataSet"];
//...whatever with CongtractDataSet
Session["ContractDataSet"]=ContractDataSet;
I want a way to create and refer to just ContractDataSEt but have it linked
to Session["ContractDataSet"] as well as ContractDataSet. I just need the
code in VB 9.
George Ter-Saakov said:Yea,
Just keep it in both places.... Session and other container/place you will
use to get those things...
---------------------------------------------------------------------------
On a serious note..... What are you trying to do.
Will HttpContext.Current.Session help?
you can access Session object from your business logic without passing
Session around....If that is what you trying to avoid.
George.
dbgrick said: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
Andy B said:I am trying to avoid having to do something like this every time I want
an
object from Session:
((DataSet)Session["ContractDataSet"]).Tables["..."]...;
or:
DataSet ContractDataSet = (DataSet)Session["ContractDataSet"];
//...whatever with CongtractDataSet
Session["ContractDataSet"]=ContractDataSet;
I want a way to create and refer to just ContractDataSEt but have it
linked
to Session["ContractDataSet"] as well as ContractDataSet. I just need the
code in VB 9.
George Ter-Saakov said:Yea,
Just keep it in both places.... Session and other container/place you
will
use to get those things...
---------------------------------------------------------------------------
On a serious note..... What are you trying to do.
Will HttpContext.Current.Session help?
you can access Session object from your business logic without passing
Session around....If that is what you trying to avoid.
George.
Is there a way to refer to things in Session object without calling
Session itself?
It ensures a) that there's no typos anywhere where the same object isThat 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...