I have a table a EmployeeManufacturer that is used to associate an employee to a manufacturer in the system. The table has three fields all primary key fields (EmployeeID, ManufacturerID, RidingStyleID). I have inserted some rows into the table using the EmployeeManufacturerEntity which works fine. Now I am trying to update the ManufacturerID for one of the employees and it doesn't work. The only thing I can figure is that because the ManufacturerID that I am trying to change is part of the primary key it won't work. I am not getting any errors and watching what happends using sql profiler only shows me that the update statement is never executed. At the moment I don't have any idea why I can't make an update of a row work.
Also, if I debug the employeeManufacturer instance where its being saved I can see that the FieldChanged property is not set to true for the ManufacturerID which I have changed.
Here is the code that I use for the update. This is using a Janus Systems asp.net GridEX control.
private void employeeManufacturerGrid_RecordUpdated(object sender, RowActionEventArgs e)
{
GridEXRow row = e.Row;
int employeeID = (int)row.CompositeDataKeyValues[0];
int manufacturerID = (int)row.CompositeDataKeyValues[1];
string styleCode = (string)row.CompositeDataKeyValues[2];
EmployeeManufacturerEntity employeeManufacturer = new EmployeeManufacturerEntity(employeeID, manufacturerID, styleCode);
employeeManufacturer.IsNew = false;
foreach(GridEXCell cell in e.Row.Cells)
{
if ( cell.DataChanged )
{
string fieldName = cell.Column.DataMember;
object cellValue = cell.Value;
if ( cellValue == null )
cellValue = string.Empty;
employeeManufacturer.SetNewFieldValue(fieldName, cellValue);
}
}
ServiceFactory.GetPersistanceManager().SaveEntity(employeeManufacturer);
}