title: Using DbSet<TEntity>.Local Property in Entity Framework
body: <p>Following <a href="https://msdn.microsoft.com/query/dev12.query?appId=Dev12IDEF1&amp;l=EN-US&amp;k=k(System.Data.Entity.DbSet%601.Local);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.5.1);k(DevLang-csharp)&amp;rd=true" rel="noreferrer">MSDN documentation</a> we can use <em>Local</em> property to get local/cached data directly from the context without additional requests to a data source:</p>
  
  <blockquote>
    <p>Gets an ObservableCollection that represents a local view of all Added, Unchanged, and Modified entities in this set.
    <br />(...)<br />
    This property can be used for data binding by populating the set with data, for example by using the Load extension method, and then binding to the local data through this property.</p>
  </blockquote>
  
  <p>The problem is, that code is not working (<em>Local</em> is empty):</p>
  
  <pre><code>context.SampleEntities.Select(x =&gt; new { x.A, x.B }).Load();
  // context.SampleEntities.Local.Count is 0
  </code></pre>
  
  <p>But in this case, it seems working correctly:</p>
  
  <pre><code>context.SampleEntities.Load();
  // context.SampleEntities.Local.Count is not 0
  </code></pre>
  
  <p>Maybe someone can explain what is the correct way to use <em>Local</em> property?
  <br />
  What is more, how to use it with partially loaded entities, like in the case above?</p>