title: Linq to SQL not filling in integer parameter
body: <p>I'm using Linq to SQL to query a table, code is below:</p>
  
  <pre><code>else if (int.TryParse(searchstring, out isID))
  {
      var events = from e in db.ov_Events
                   where e.Event_Id == isID
                   select e;
  
      success = true;
      error = "";
      return events.ToList();
  }
  </code></pre>
  
  <p>This section of code performs the following query:</p>
  
  <pre><code>SELECT [t0].[Event_Id], [t0].[Event_Name]...
  FROM [dbo].[ov_Events] AS [t0]
  WHERE [t0].[Event_Id] = @p0
  </code></pre>
  
  <p>This then returns an error from the database "Must declare scalar variable @p0".</p>
  
  <p>I don't understand why linq isn't supplying the variable to the server (SQL Server Express 2014).</p>
  
  <p>I've even tried the following:</p>
  
  <pre><code>    var events = from e in db.ov_Events
                   where e.Event_Id == 1
                   select e;
  </code></pre>
  
  <p>This still runs the same exact query, not sure where I've gone wrong?</p>
  
  <p>Full code below:</p>
  
  <pre><code>using (DB_v1DataContext db = new DB_v1DataContext(Con)) {
      int isID;
      try {
          if (searchstring == "") {
              var events = from e in db.ov_Events
                           select e;
              success = true;
              error = "";
              return events.ToList();
          } else if (int.TryParse(searchstring, out isID)) {
              var events = from e in db.ov_Events
                           where e.Event_Id == isID
                           select e;
              success = true;
              error = "";
              return events.ToList();
          } else {
              var events = from e in db.ov_Events
                           where e.Event_Name.Contains(searchstring) 
                           || e.Event_Notes.Contains(searchstring)
                           select e;
  
              success = true;
              error = "";
              return events.ToList();
  
          }
      } catch (Exception ex) {
          success = false;
          error = "Error Getting Events:" + ex.Message;
          return null;
      }
  }
  </code></pre>