title: Deleting Row from Database C# WPF Linq
body: <p>I want to delete a row from the Database on a selected row in my Datagrid
  I already got how to select a row in my Datagrid, but when I delete it on button_click it only deletes  it in my Datagrid but not in my actual Database</p>
  
  <p>I'm using the following code to delete my Rows:</p>
  
  <pre><code>private void btnDeleteUser_Click(object sender, RoutedEventArgs e)
      {
          DialogResult dr = System.Windows.Forms.MessageBox.Show("Do You Want to Delete this User?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
  
          if (dr == DialogResult.Yes)
          {
              var query =
                  from t in db.tbl_Users
                  where t.Name == name
                  select t;
  
              foreach (var t in query)
              {
                  db.tbl_Users.DeleteOnSubmit(t);
              }
  
              db.SubmitChanges();
  
              var refresh =
                          (from q in db.tbl_Users
                           select new { Name = q.Name, Rights = q.Rights, Operatortag = q.Operatortag, Active = q.Active, Cardcode = q.CardCode }).ToList();
  
              dgUsers.ItemsSource = refresh;
          }
      }
  </code></pre>
  
  <p>My Database-property is set on Copy If Newer and I already tried to set in to Copy Always but that wouldn't help either.</p>
  
  <p>Does someone know the answer to my problem?</p>