title: LINQ: "Enumeration yielded no results"
body: <p>I am having a terrible time trying to get a LINQ statement working.</p>
  
  <p>I have tried using both SQL syntax and lambda following this post:</p>
  
  <p><a href="https://stackoverflow.com/questions/2767709/c-sharp-joins-where-with-linq-and-lambda">C# Joins/Where with Linq and Lambda</a></p>
  
  <p>This is what my working SQL looks like:</p>
  
  <pre><code>SELECT ws_lookup_OccupationGroup.Code
  FROM ws_lookup_OccupationGroup
  INNER JOIN ws_lookup_Occupation ON
  ws_lookup_OccupationGroup.Code = ws_lookup_Occupation.ws_lookup_OccupationGroup_Code
  WHERE (ws_lookup_Occupation.Code = N'413')
  </code></pre>
  
  <p>This is my first attempt and it yields no results:</p>
  
  <pre><code>var query = from occupationGroup in db.ws_lookup_OccupationGroups 
              join occupations in db.ws_lookup_Occupations on occupationGroup.Code equals occupations.Code 
              where occupations.Code == model.Client.Client_Details_Enhanced.Occupation.Code 
              select new 
              { 
                  OccupationGroup = occupationGroup, 
                  Occupations = occupations 
              };
  </code></pre>
  
  <p>Here is my second attempt using Lamdba which also yields no results:</p>
  
  <pre><code>var queryLambda = db.ws_lookup_OccupationGroups
                      .Join(db.ws_lookup_Occupations, 
                            occupation =&gt; occupation.Code, 
                            occupationGroup =&gt; occupationGroup.Code,
                            (occupation, occupationGroup) =&gt; new 
                            { 
                                OCCUPATION = occupation, 
                                OCCUPATIONGROUP = occupationGroup 
                            })
                      .Where(all =&gt; all.OCCUPATION.Code == model.Client.Client_Details_Enhanced.Occupation.Code);
  </code></pre>
  
  <p>I just cannot see what is going wrong...</p>
  
  <p>I don't know is this has any relevance but I am using Code First Entity Framework - he is my model for OccupationGroups &amp; Occupations:</p>
  
  <pre><code>public class ws_lookup_OccupationGroup {
      [Key]
      [MaxLength(250)]
      public string Code { get; set; }
      [MaxLength(250)]
      public string Name { get; set; }
      public int SortOrder { get; set; }
      public List&lt;ws_lookup_Occupation&gt; Occupations { get; set; }
  }
  public class ws_lookup_Occupation {
      [Key]
      [MaxLength(10)]
      public string Code { get; set; }
      [MaxLength(250)]
      public string Name { get; set; }
      [MaxLength(250)]
      public string BarbadosMotorFactor { get; set; }
      [MaxLength(250)]
      public string TrinidadMotorFactor { get; set; }
      [MaxLength(250)]
      public string OtherRegionsMotorFactor { get; set; }
  }
  </code></pre>