title: Using "Match" in a Linq statement
body: <p>I have a table that has two records (there will be many at runtime). The <code>deviceId</code> of the records are, “DEVICE1” and “DEVICE2”. I want to use a regular expression to extract records.</p>
  
  <p>The code below compiles but fails to return a result. When I hover the cursor on the “devices.ToList()” statement I get the following error:</p>
  
  <p><code>base {System.SystemException} = {"LINQ to Entities does not recognize the method 'System.Text.RegularExpressions.MatchCollection Matches(System.String)' method, and this method cannot be translated into a store expression."}”</code></p>
  
  <p>Can anyone show me how I can modify my query so that this would return records based on the expression?</p>
  
  <pre><code>filterText = @"DEVICE.";
  Regex searchTerm = new Regex(filterText);
  
  using (var ctx = new MyEntities())
  {
   var devices = from d in ctx.Devices
                  let matches = searchTerm.Matches(d.DeviceId)
                  where matches.Count &gt; 0
                  select ((Device)d);
  return devices.ToList();
  }
  </code></pre>