title: LINQ2SQL: how to delete entity by retrieving it from datagridview?
body: <p>I have a datagridview and attached list of Employees to it, somthing like this:<br/></p>
  
  <pre><code>IQueryable&lt;Employee&gt; data = (from em in db.Employees
                               where em.StationID == stationID
                               select em);
  dgvView.DataSource = data;
  </code></pre>
  
  <p><br/>
  Now I want to delete specific Employee by selected row in datagridview:<br/></p>
  
  <pre><code>using (PetrolNetwork db = new PetrolNetwork())
                  {
                      Employee empl = (Employee)dgvView.CurrentRow.DataBoundItem;
                      db.Employees.DeleteOnSubmit(empl);
                      db.SubmitChanges();
                  }
  </code></pre>
  
  <p>Not surprise, that I've got exception "<em>Cannot remove an entity that has not been attached.</em>"<br >
  When I replace this code by:<br ></p>
  
  <pre><code>Employee employee = (from em in db.Employees
                                           where em.ID == empl.ID
                                           select em).Single();
                      db.Employees.DeleteOnSubmit(employee);
                      db.SubmitChanges(); 
  </code></pre>
  
  <p>all work correctly, <strong>but</strong> in sqlprofiler we can see one extra select to database to retrieve our specific employee, and then delete from statement.<br > How I can delete my employee, when I got it from DataBoundItem from datagridview without any extra select statements? One approach that I can see is custom sproc to delete by ID. May be there is any other best approaches? </p>