Answer the question
In order to leave comments, you need to log in
Updating a Record in Entity Framework
I use MSSQL Server 2008 and 2010 studio.
Trying to update the selected entry:
try
{
//указываю выбраную запись в DataGrid
Model.paket selPaket = (paket)paketDataGrid.SelectedItem;
using (MagnesiumEntities _cnt = new MagnesiumEntities())
{
//выбираем запись по id
var pakToDetach = _cnt.pakets.FirstOrDefault(p => p.id == selPaket.id);
if (pakToDetach == null)
throw new Exception("Product already deleted");
//изменяю массу брутто и нетто
pakToDetach.mBrutto = selPaket.mBrutto;
pakToDetach.mNetto = selPaket.mNetto;
_cnt.SaveChanges();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question