What does NHibernate Session.Evict do?
-
07-09-2020 - |
题
What does the following code snippet do? Why the use of Evict
?
private void DoEvict(customer cust)
{
AddressRepository.Evict(cust.Address);
cust.Address = AddressRepository.Get(cust.Address.Id);
}
解决方案
The evict removes that specific "Address" reference from the NHibernate first level cache.
If the first instruction in your code snippet was not executed, the second one, instead of fetching the item from the DB, would simply return it from the first level cache.
其他提示
Session.evict() is used to remove a particular object from Persistent state to Detached state.
不隶属于 StackOverflow