Hi,
I've got a Service I'm attempting to move over to NHibernate.
Theres a Get method on the service that is called via a cancel button on the view. The first time the Get method is called (the first time I cancel a change) the cancel actually happens and the value returns.
The second time I cancel, it just ignores the cancel and keeps the new value?!
private ISession _session;
private ISession GetSession()
{
return _session ?? (_session = _sessionFactory.OpenSession());
}
public MappingCollection Get(string id)
{
var session = GetSession();
var mappingCollection = session.Get<MappingCollection>(id);
return mappingCollection;
}
However if I change the Get(string id) to include a refresh ...
public MappingCollection Get(string id)
{
var session = GetSession();
var mappingCollection = session.Get<MappingCollection>(id);
session.Refresh(mappingCollection);
return mappingCollection;
}
Everything works - but looking with NHibernate Profiler it calls the select twice on the first operation ... I know I could add a bool to see if its been run, but i'm hoping theres a better way!
Can anyone help please? Thanks