Marten OpenSession() 与 LightweightSession()

Marten OpenSession() vs LightweightSession()

我是 marten 的新手。
IDocumentStore.OpenSession()IDocumentStore.LightweightSession() 有什么区别?

基于xmldoc只是一个方便的方法:

Convenience method to create a new "lightweight" IDocumentSession with no IdentityMap or automatic dirty checking

在当前的实现中,它只是 calls OpenSessionDocumentTracking 设置为 DocumentTracking.None

也来自 troubleshooting docs:

From

IDocumentStore.OpenSession

Characteristics:

Defaults to session that tracks objects by their identity, DocumentTracking.IdentityOnly, with isolation level of Read Committed.

Use: Reading & writing data. Objects within a session are cached by their identity. Updates to objects are explicitly controlled through session operations (IDocumentSession.Update, IDocumentSession.Store). With the defaults, incurs lower overhead than DirtyTrackedSession.

From

IDocumentStore.LightweightSession

Characteristics:

No change tracking, DocumentTracking.None, with the default isolation level of Read Committed.

Use: Reading & writing data. No caching of objects is done within a session, e.g. repeated loads using the same document identity yield separate objects, each hydrated from the database. In case of updates to such objects, the last object to be stored will overwrite any pending changes from previously stored objects of the same identity. Can incur lower overhead than tracked sessions.