title: Converting complex result set from stored procedure into entities and their children
body: <p>I have a stored procedure that returns a series of joined table results as one of several result sets, ala:</p>
  
  <pre><code>SELECT 
      a.*,
      at.*
  FROM
      dbo.UserProfile up
  JOIN
      dbo.Players p ON up.UserId = p.UserId
  JOIN
      dbo.PlayerAbilities pa ON p.PlayerId = pa.PlayerId
  JOIN
      dbo.Abilities a ON pa.AbilityId = a.AbilityId
  JOIN
      dbo.Attributes at ON a.AttributeId = at.AttributeId
  WHERE
      up.UserName = @userName
  </code></pre>
  
  <p>My entity class structure for the Ability class is as follows:</p>
  
  <pre><code>class Ability
  {
      /* Standard Properties */
  
      public Attribute Attribute { get; set; }
  }
  </code></pre>
  
  <p>When I call this stored procedure with code:</p>
  
  <pre><code>//Establish that var reader = (stored procedure).ExecuteReader()
  var abilities = ((IObjectContextAdapter)context)
                          .ObjectContext
                          .Translate&lt;Ability&gt;(reader);
  </code></pre>
  
  <p>I get a collection of Ability objects but their Attribute property is not populated.  How can I modify my stored procedure or instruct entity framework to allow for this property to be populated?</p>
  
  <p>EDIT: Attribute and Ability Table schemas as requested:</p>
  
  <pre><code>TABLE Attributes
  {
      AttributeId INT PKEY
      AttributeName VARCHAR(50)
  }
  TABLE Abilities
  {
      AbilityId INT PKEY
      AbilityName VARCHAR(50)
      AbilityDescription VARCHAR(500)
      AttributeId INT FKEY =&gt; Attributes.AttributeId
      ClassificationId INT FKEY =&gt; Classifications.ClassificationId
      BaseDamage INT
      LevelRequired INT
      PriceId INT FKEY =&gt; Prices.PriceId
      RecordStatusId INT FKEY =&gt; RecordStatuses.RecordStatusId
  }
  </code></pre>
  
  <p>Forgot to add this in the original edit:</p>
  
  <pre><code>class Attribute
  {
      public int AttributeId { get; set; }
      public string AttributeName { get; set; }
      public ICollection&lt;Ability&gt; Abilities { get; set; }
  
      //Never used, doesn't matter for lazy loading though, never got around to deleting
      public virtual ICollection&lt;Monster&gt; Monsters { get; set; }
      public virtual ICollection&lt;Monster&gt; Monsters1 { get; set; }
  }
  </code></pre>
  
  <p>I didn't originally include classification/price/recordstatus column information in the above properties problem because I though it would be redundant, but I've included them here in case it's relevant.</p>