title: Returning related entities from functions in OData Web Api
body: <p>I've created an OData v4 endpoint using ASP.NET Web API 2.2 with 2 entities: </p>
  
  <p><a href="https://i.stack.imgur.com/1v3tw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1v3tw.png" alt="enter image description here"></a></p>
  
  <p>And i made function in my controller, that returns entity with related entity by using Include in LINQ:</p>
  
  <pre><code>[HttpGet]  
    [ODataRoute("SalaryNaryadWork/TechOrder.Functions.GetNaryadSalaryWork(pNaryadID={pNaryadID})")]
  public IHttpActionResult GetNaryadSalaryWork(int pNaryadID)
  {
  var tmp =_ctx.SALARY_NARYAD_WORK.Include(s =&gt; s.SALARY_WORK_LIST).Where(sw =&gt; sw.NARYAD_ID == pNaryadID).ToList();
  return Ok(tmp);
  }
  </code></pre>
  
  <p>Function configuration code is:</p>
  
  <pre><code>var GetNaryadSalaryWork = builder.EntityType&lt;SALARY_NARYAD_WORK&gt;().Collection.Function("GetNaryadSalaryWork");
  GetNaryadSalaryWork.Parameter&lt;int&gt;("pNaryadID");
  GetNaryadSalaryWork.ReturnsCollectionFromEntitySet&lt;SALARY_NARYAD_WORK&gt;("SalaryNaryadWork");
  GetNaryadSalaryWorkList.Namespace = "TechOrder.Functions";
  </code></pre>
  
  <p>But when I call this function by link <code>../SalaryNaryadWork/TechOrder.Functions.GetNaryadSalaryWork(pNaryadID=1)</code> I get only my entity without related entity:</p>
  
  <p><a href="https://i.stack.imgur.com/M491H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M491H.png" alt="enter image description here"></a></p>
  
  <p>Despite the fact that function returns related entity either (I saw that in variable <code>tmp</code> when debug function in visual studio)</p>
  
  <p>So my question, is it possible to fix that and get related entity exactly by function without using expand option on <code>Get()</code> controller function?</p>