I'm trying to delete a selected row in my datagrid as well as that same row in my database.
I'm getting an error though where dbset does not contain a definition for SaveChanges
.
Relatively new to Linq and EF. Anyone know where this might be coming from?
private void DeleteButton_Click(object sender, RoutedEventArgs e) { using (EFContext db = new EFContext()) { int proId = (ProductDatagrid.SelectedItem as Product).ProductID; Result result = (from r in db.products where r.ProductID == proId select r).SingleOrDefault(); db.Product.Remove(result); db.Product.SaveChanges(); ProductDatagrid.ItemsSource = db.Results.ToList(); } }
https://stackoverflow.com/questions/67307927/dbset-does-not-contain-definition-for-savechanges April 29, 2021 at 05:09AM
没有评论:
发表评论