Why have a session class and not store this information in your custom Identity class (e.g. PTIdentity equivalent) and just query that on your DataPortal_XYZ methods?
I could only understand if the information might change for a single user during his session using your app. In that case why not pass it in as criteria in your GetObject static class? So for example you would have something like:
public static Customer GetCustomer(int id, Session session)
{
return Dataportal.Fetch<Customer>(new CustomerCriteria(id,session));
}
private class CustomerCriteria
{
private int _id;
private Session _session;
public int Id { get { return _id; } }
public Session Session { get { return _session; } }
public CustomerCriteria(int id, Session session)
{
_id = id;
_session = session;
}
}
protected override void DataPortal_Fetch(object criteria)
{
<use the connectionstring property of your Session class to open the connection>
}
Finally, a last option would be to pass the Session object in your static "New" method so for example:
public static Customer NewCustomer(Session session)
{
this._session = session;
}
And then you have your private member _session in your DataPortal_XYZ methods.
It depends what you want. Just dont use the constructors directly :-)
Copyright (c) Marimer LLC