title: Linq to entities - first letter of string between 2 keys
body: <p>I'm using Entity Framework and have come across an issue with the lack of support for certain extensions.</p>
  
  <p>I have 2 keys (both char) <code>fromKey</code> and <code>toKey</code> and am looking to construct a <code>Where</code> statement that will search a list of <code>Stores</code>, and select where the first letter of <code>Store.Name</code> is between <code>fromKey</code> and <code>toKey</code>.</p>
  
  <p><code>string[0]</code> does not work, <code>Substring</code> does not work - anyone got any ideas how to get round this? </p>
  
  <p>Code for substring method:</p>
  
  <pre><code>public static IQueryable&lt;Store&gt; FindActiveByName()
  {
      var r = new ReadRepo&lt;Store&gt;(Local.Items.Uow.Context);
  
      Tuple&lt;string, string&gt; range = Tuple.Create("0", "9");
      return r.Find().Where(s =&gt; range.Item1 &lt;= s.Name.Substring(0, 1) &amp;&amp;
                                 s.Name.Substring(0, 1) &lt;= range.Item2);
  }
  </code></pre>
  
  <p>Gives me an error:</p>
  
  <blockquote>
    <p>Operator &lt;= cannot be applied to string</p>
  </blockquote>
  
  <p>UPDATE </p>
  
  <p>Anwser provided by nemesV</p>
  
  <pre><code>    public static IQueryable&lt;Store&gt; FindActiveByName()
      {
          Tuple&lt;char, char&gt; range = Tuple.Create('R', 'S');
  
          var r = new ReadRepo&lt;Store&gt;(Local.Items.Uow.Context);
  
          var keys = Enumerable
              .Range(range.Item1, (int)range.Item2 - (int)range.Item1 + 1)
              .Select(k =&gt; ((char)k).ToString());
  
          return r.Find(s =&gt; keys.Contains(s.Name.Substring(0, 1)));
      }
  </code></pre>