title: Raw SQL result has it, result of ObjectContext.Translate<T> doesn't
body: <p>I am able to replicate something I would have bet that is not true :-)
  Entity-Framework-5 based application is populating an entity named "dbSetName" from stored procedure result, like this:</p>
  
  <pre><code>DbContext.Database.Initialize(false);
  IDbCommand cmd = DbContext.Database.Connection.CreateCommand();
  cmd.CommandType = CommandType.StoredProcedure;
  cmd.CommandText = sprocName;
  DbContext.Database.Connection.Open();
  using (DbDataReader reader = (DbDataReader)cmd.ExecuteReader())
  {
      var tmpresult = ((IObjectContextAdapter)this.DbContext).ObjectContext.Translate&lt;T&gt;(reader, dbSetName, MergeOption.AppendOnly);
  </code></pre>
  
  <p>The reader is <code>SqlDataReader</code>. DbContext is derived from System.Data.Entity.DbContext - nothing fancy.</p>
  
  <p>The stored procedure output, when I execute in SSMS, spits a single set - the result of the first and only stand-alone SELECT in its body. It consists of 3383 records.</p>
  
  <p>The contents of tmpresult, when enumerated consists of 3383 records, but CONSISTENTLY and without apparent reason, a few records I see in the raw output are replaced with duplicates of records in the raw output.</p>
  
  <p>For example, <strong>RAW</strong> output looks like this</p>
  
  <p>Row Values</p>
  
  <ol>
  <li>1.1   1.2   1.3</li>
  <li>2.1   2.2   2.3</li>
  <li>3.1   3.2   3.3</li>
  <li>4.1   4.2   4.3</li>
  <li>5.1   5.2   5.3
  ...</li>
  </ol>
  
  <p>But the result in tmpresult is consistently like that:</p>
  
  <p>Row Values</p>
  
  <ol>
  <li>1.1   1.2   1.3</li>
  <li>2.1   2.2   2.3</li>
  <li>3.1   3.2   3.3</li>
  <li><strong><em>2.1   2.2   2.3</em></strong></li>
  <li>5.1   5.2   5.3
  ...</li>
  </ol>
  
  <p>I can stop in the debugger, examine and ensure that I am executing the raw against same SQL server/database/sproc that EF uses... <strong>Bizarre...</strong></p>
  
  <p>Not sure what additional info to show, but I hope someone could explain this.</p>
  
  <p><strong>ADDITIONAL INFO</strong>: Replacing <code>Objectcontext.translate&lt;T&gt;</code> with <code>SqlQuery&lt;T&gt;</code> removes the issue. So do I now debug whatever assembly implements <code>Objectcontext.translate&lt;T&gt;</code>?</p>