After some toying around, I have my first object Saving/Updating/Deleting and using a GetAll method to bind to a Datagrid. All of this with about 5 or 6 lines of UI code! Yummy!
I still have some design concerns to wrinkle out, though. Here's how I have mine set up:
public class NHManager
{
public NHManager()
{
}
}
public abstract class BusinessBase
{
private static NHManager _mgr = null;
[ThreadStatic()]
protected static NHManager Manager
{
get
{
if( _mgr == null)
_mgr = new NHManager();
return _mgr;
}
}
private ISession _session = null;
protected ISession CurrentSession
{
get
{
if( _session == null )
{
if( HttpContext.Current[NHSESSION] == null )
{
_session = Manager.OpenSession();
HttpContext.Current[NHSESSION] = _session;
}
else
{
_session = HttpContext.Current[NHSESSION]
as ISession;
}
}
if(! _session.IsConnected)
_session.ReConnect();
return _session;
}
}
}
Is there anything glaringly wrong about the above sample? I am expecting a little flaming due to the [ThreadStatic()] in my ASP.NET Application, but is it really that bad since my manager object is WORM (Write Once Read Many) ???
I welcome suggestions and comments (now that they will actually work :P )