title: Get all tracked entities from a DbContext?
body: <p>Many of the tables in my database need to have a "DateCreated" and "DateModified" column. I want to update these columns whenever <code>SaveChanges()</code> is called.</p>
  
  <p>All my model objects inherit from a class <code>AbstractModel</code> to allow this kind of behavior. The class looks like this:</p>
  
  <pre><code>public abstract class AbstractModel {
      public virtual void UpdateDates() { }
  }
  </code></pre>
  
  <p>I then plan to override <code>UpdateDates()</code> in any child classes that have <code>DateCreated</code> and <code>DateModified</code> fields they need to maintain.</p>
  
  <p>To use this, I need to be able to get a list of all the entities that the <code>DbContext</code> is tracking, and call <code>UpdateDates()</code> on them if the object is marked as being <code>Added</code> or <code>Modified</code>.</p>
  
  <p>I can't seem to get access to wherever <code>DbContext</code> is storing this information. I can do <code>dbContext.Entry(object).State</code> to get the <code>EntityState</code> of a single entity, but I can't work out how to get a list of all tracked entities.</p>
  
  <p>How do I do this?</p>