This is my code:
...
Domain.Box updatedBox = entities.Boxes.FirstOrDefault(TextBoxBoxID.Text);
updatedBox = getBoxInfo();
entities.SaveChanges();
private Domain.Box getBoxInfo()
{
Domain.Box retBox = new Domain.Box();
retBox.BoxID = TextBoxBoxID.Text;
retBox.LocationID = Convert.ToDecimal(TextBoxLocationID.Text);
retBox.Positions = Convert.ToByte(TextBoxPositions.Text);
retBox.DiseaseID = RadComboBoxDisease.SelectedValue;
retBox.SampleTypeID = RadComboBoxSampleType.SelectedValue;
retBox.TubeTypeId = RadComboBoxTubeTypeID.SelectedValue;
return retBox;
}
The code compiles and executes fine, but the database does not changes, this is, all the information is exactly the same as it was before the update. Any help will be appreciated, thanks!
If you want to insert a new Domain.Box object, you should do it like this:
There is no need to create the
updatedBoxobject because you’re just overwriting it. If I understand you’re requirements, you want to perform an insert, not an update.If I’m incorrect and you’re trying to update certain properties of the
updatedBoxobject, then just pass a reference to the object and update it’s properties: