title: how to use substring in ef query within where and select statement
body: <p>Hi there how to use <code>substring</code> in <code>EF</code> query within <code>where</code> and <code>select</code> statements?</p>
  
  <p>my query does not count any record from database to execute </p>
  
  <p>but in database having 13359 records </p>
  
  <p>My query is below </p>
  
  <pre><code>string subautoassettype, subautocat, subautocat1 ;
  string autoidstring;
  
  autocat = cmbcategory.Text;
  autocat1 = cmbcategory1.Text;
  autocat2 = cmbcategory2.Text;              
  subautoassettype = autocat.Substring(0, 3);
  subautocat = autocat1.Substring(0, 3);
  subautocat1 = autocat2.Substring(0, 3);
  
  autoidstring = subautoassettype + subautocat + subautocat1 + "-";
  
  var varmaxidcheck = cnx.item_master.Where(c =&gt; c.Item_ID.Substring(0, 9) == autoidstring)
                         .Select(gd =&gt; new { gd.Item_ID }).ToList();
  
  
  if (varmaxidcheck.Count &gt; 0)
  {
      foreach (var it11 in varmaxidcheck)
      {
          string kij = it11.Item_ID;
      }
  }
  </code></pre>
  
  <p>Sample Output expect :</p>
  
  <pre><code>cnx.item_master(where c=&gt; c.FixBooChe-0013346 == FixBooChe-).Select(fg=&gt;fg.Item_ID);
  </code></pre>
  
  <p>Pls help me to solve this issue</p>
  
  <p>Also I have include SQL query</p>
  
  <pre><code>select max(substring(Item_ID,11,6)) from item_master where substring(Item_ID,1,9) = 'FixEleCre';
  </code></pre>