开发者

NHibernate Session.Flush & Evict vs Clear

In a test where I want to persist an object and then prove it was persisted 开发者_如何学Cby fetching it from the db (and not the session), I notice no difference between the following:

// save it
session.Clear()
// fetch it

or

// save it
session.Flush()
session.Evict(_instance)
// fetch it

The lazy programmer in me leans towards one line over two. Is there some reason I am missing to favor the two lines more?


session.Clear actually cancels all pending saves/updates/etc.

If it doesn't, it's because you're using identity so the entity is persisted without flushing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜