title: Recursive self join
body: <p>I have table as below. I need to get all the manager id's for the user id provided.</p>
  
  <pre><code>userid managerid
  10     1
  9      10
  6      9
  2      6
  4      1
  </code></pre>
  
  <p>If i pass 2 to my method I need to get 1,10,9 and 6. I have written the below query which will return only first level parent. I.e it will return only 6 &amp; 9.</p>
  
  <pre><code>public List&lt;int?&gt; mymethod (int userId){
  
  return (from e in mycontext.EmployeeManagers
                       join e1 in m_context.EmployeeManagers
                          on e.UserId equals e1.ManagerId
                      where e1.UserId == userId
                       select e1.ManagerId).AsQueryable().ToList()
  }
  </code></pre>
  
  <p>How can I modify the query to return all the manager hirerachy?</p>
  
  <p>please help.</p>