Temp modification of NHibernate Entities
Is there a way I can tell Nhibernate to ignore any future changes on a set of objects retrieved using it?
public ReturnedObject DoIt()
{
List<MySuperDuperObject> 开发者_开发知识库awesomes = repository.GetMyAwesomenesObjects();
var sp = new SuperParent();
BusinessObjectWithoutNHibernateAccess.ProcessThese(i, awesomes,sp)
repository.save(sp);
return i;
}
public ReturnedObject FakeIt()
{
List<MySuperDuperObject> awesomes = repository.GetMyAwesomenesObjects();
var sp = new SuperParent();
// should something go here to tell NHibernate to ignore changes to awesomes and sp?
return BusinessObjectWithoutNHibernateAccess.ProcessThese(awesomes,sp)
}
You can evict the objects from the session. See the method ISession.Evict
.
精彩评论