Is there a chance that in a future version of Raven you could expose a method that returns the all the changed entities? You already have HasChanges() and HasChanged(...), it is not much of a stretch return an enumeration of entities that have changed from a similarly named method, and this would solve my problem the most cleanly. If it is helpful, I could even volunteer a pull request.
Although the contextual listeners library will not work for me (because it requires a context to be supplied before I can know anything has changed), the concept it is built on can work for me, but it does seem a little messy. The issue here is that I have to modify the audit document in the BeforeStore(...) event of all the other changed entities. This means that I rely on the audit document calling the listener last (which in practice does seem to be working), and then I have to return true if the entity is my audit entity, even though the listener didn't change the audit entity in that BeforeStore(...) call.
```
Listener Pseudo Code:
public class AuditListener : IDocumentStoreListener {
public bool BeforeStore(...) {
if (entityInstance is Audit) return true; // <-- return true even though I didn't change Audit in this scope seems bad, it relies on an implicit order of operations that has happened in previous BeforeStore(...) calls
if (AuditExists) UpdateAuditModifiedEntry(entityInstance); //Audit is already in the document session
return false;
}
...
}
```