title: System.Core error: "Code supposed to be unreachable" using C# Entity Framework and Linq with Expression
body: <p>I'm getting a "Code supposed to be unreachable" error when executing the following Linq to Sql statement. I'm using EF 6.1.3. I think this is a known bug related to filtering a navigation property. It seems like it might be fixed in EF7 but I don't see anything related to this in the EF 6.2 release notes nor the EF6 open items on GitHub so I guess I'm looking for a work around, maybe a different way of writing my Linq statement. </p>
  
  <p>Ultimately, I am applying the same where clause (AccountSecurity) in multiple places (also based on passing a user key parameter) so I thought I'd be able to turn it into a function that generates the Expression to use in the where clause in my Linq to Sql statement.</p>
  
  <pre><code>    public List&lt;Company&gt; GetCompanyList(int p_UserKey, MemberType p_MemberType)
      {
          var qry = from cs in this.DbContext.CompanySet
                    .Where(c =&gt; c.Accounts.AsQueryable().Any(this.AccountSecurity(p_UserKey)))
                    select cs;
          return qry.ToList();
      }
  
      private Expression&lt;Func&lt;Account, bool&gt;&gt; AccountSecurity(int p_UserKey)
      {
          return (ac =&gt; ac.UserAccounts.Any(ua =&gt; ua.UserKey == p_UserKey));
      }
  </code></pre>