Exposing list of currently tracked entities in session

63 views
Skip to first unread message

Nik

unread,
Jan 19, 2021, 5:58:42 AM1/19/21
to RavenDB - 2nd generation document database
Hi, 

I had a similar question about 2 years ago so wondering if the stance on this topic might have changed.

Would it be possible to expose a list of entities tracked by a document session?

I am using reflection to get that list by accessing DocumentSession.DocumentsByEntity, but I'd prefer not to use such ugly workarounds : )

There might be different scenarios requiring this, I'll list 2:

- Before calling "SaveChanges()" do some operations based on tracked aggregate roots. For example, publish domain events held by the agg. roots, if there are any. Using the sessions before-save event would not work here as sometimes there is no change on the aggregate root but a related entity. There may be more scenarios why the built-in events do not suffice here and why it would be cleaner just to get a list of tracked entities.

- We load an entity by Id. Then another module we can't change tries to load the same entity by a uniquely constrained parameter. To prevent another DB request for the query we can look up the tracked entities if we already loaded the document.

Egor Shamanaev

unread,
Jan 20, 2021, 4:58:11 AM1/20/21
to rav...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ravendb/cdc0975f-b537-4db9-95dc-ba43eb50ba1an%40googlegroups.com.


--
Egor
Developer   /   Hibernating Rhinos LTD
Support:  sup...@ravendb.net
  

Nik

unread,
Jan 20, 2021, 5:11:41 AM1/20/21
to RavenDB - 2nd generation document database
Hi Egor,

That seems to be an internal call.

Egor Shamanaev

unread,
Jan 20, 2021, 9:27:19 AM1/20/21
to rav...@googlegroups.com
Hi

Yes you are right, I have opened an issue to add this: https://issues.hibernatingrhinos.com/issue/RavenDB-16148


Nik

unread,
Jan 21, 2021, 2:35:55 AM1/21/21
to RavenDB - 2nd generation document database
Thanks, looks good.
Reply all
Reply to author
Forward
0 new messages