c# update entity object from winforms client northwind Customers example

private void Guncelle()
{
if (string.IsNullOrEmpty(this.textBoxCompanyName.Text.Trim())){MessageBox.Show("Company Name Olmalıdır");return;}
if (string.IsNullOrEmpty(this.textBoxCustomerID.Text.Trim())){MessageBox.Show("Customer ID Olmalıdır");return;}
//................................
try
{
ServiceReferenceNorthWind.NorthwindEntities ne = GetNe();
string custID = this.textBoxCustomerID.Text.Trim();

var delCust = (from cst in ne.Customers
where cst.CustomerID == custID
select cst).FirstOrDefault();

delCust.CompanyName = this.textBoxCompanyName.Text.Trim();
ne.UpdateObject(delCust);
ne.SaveChanges();
}
catch (Exception ex){MessageBox.Show("Guncelle" + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException);return;}
//............................
BilgileriGetir();
//............................
}


Yorumlar