title: Entity Framework LInq Query Lambda Syntax Where Clause
body: <p>I am trying to use the Include, ThenInclude and Where clause to produce the proper data from the database. This will work fine when When check the equality of the Id property in the where clause. But if i check for the equlity of a string it doesnt work. </p>
  
  <p>Database:</p>
  
  <p>Linq Query 1: </p>
  
  <pre><code>public List&lt;Company&gt; GetGateways()
  {
      return DbSet
          .Include(c =&gt; c.Elements).ThenInclude(e =&gt; e.Attributes)
          .Include(c =&gt; c.Elements).ThenInclude(e =&gt; e.ElementType).Where(o =&gt; o.Id == 1)
          .Include(o =&gt; o.Users)
          .ToList();
  }
  </code></pre>
  
  <p>SQL output:</p>
  
  <pre><code>   SELECT [a].[Id], [a].[Active], [a].[Created], [a].[ElementId], [a].
  
      [Key], [a].[Updated], [a].[Value]
      FROM [Attributes] AS [a]
      INNER JOIN (
          SELECT DISTINCT [c].[Id], [e].[Id] AS [Id0]
          FROM [Elements] AS [e]
          INNER JOIN (
              SELECT DISTINCT [c].[Id]
              FROM [Companies] AS [c]
              WHERE [c].[Id] = 1
          ) AS [c] ON [e].[CompanyId] = [c].[Id]
      ) AS [e] ON [a].[ElementId] = [e].[Id0]
      ORDER BY [e].[Id], [e].[Id0]
  </code></pre>
  
  <p>Linq Query 2: (Does not Work)</p>
  
  <pre><code>public List&lt;Company&gt; GetGateways()
  {
      return DbSet
          .Include(c =&gt; c.Elements).ThenInclude(e =&gt; e.Attributes)
          .Include(c =&gt; c.Elements).ThenInclude(e =&gt; e.ElementType).Where(o =&gt; o.Name == "Gateway")
          .Include(o =&gt; o.Users)
          .ToList();
  }
  </code></pre>
  
  <p>SQL Output 2:</p>
  
  <pre><code>SELECT [c].[Id], [c].[Active], [c].[Created], [c].[Name], [c].[Updated]
  FROM [Companies] AS [c]
  WHERE [c].[Name] = 'Gateway'
  ORDER BY [c].[Id]
  </code></pre>
  
  <p>Any ideas where i am going wrong with my linq query?</p>