开发者

What does NHibernate Session.Evict do?

开发者 https://www.devze.com 2023-03-07 11:29 出处:网络
What does the following code snippet do? Why the use of Evict? private void DoEvict(customer cust) { AddressRepository.开发者_运维百科Evict(cust.Address);

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消