在Nhibernate中刷新实体的最佳方法是什么 [英] What's the best way to refresh entities in nhibernate

查看:102
本文介绍了在Nhibernate中刷新实体的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想刷新一个实体及其所有子集合.做这个的最好方式是什么?我说的是nhibernate:)

I would like to refresh an entity and all its child collections. What is the best way to do this? I'm talking about nhibernate:)

我已经了解了session.Evict,session.Refresh ...

I've read about session.Evict, session.Refresh...

但是我仍然不确定是否要这样做:

But I'm still not sure if doing like:

RefreshEntity<T>(T entity)
{
 session.Evict(entity);
 session.Refresh(entity);
}

将完全按照我希望的方式工作

would work exactly how I want it to work

这行得通吗?如果没有,我还能做什么?

Is it going to work? If not What else I can do?

推荐答案

驱逐后刷新可能无效.

理论上,仅Refresh就足够了.但是,删除子集合的元素时存在已知问题.

Theoretically, Refresh alone should be enough. However, it has known issues when elements of child collections have been deleted.

Evict后跟Get通常可以完成任务.

Evict followed by Get usually gets things done.

这篇关于在Nhibernate中刷新实体的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆