views:

54

answers:

0

In the following code, if one of the values assigned violates a database constraint, the Save() updates the record with the other good values. However, the database constraint does not appear to bubble up and and be caught by SubSonic. Does SubSonic provide a way to catch constraint violations like this?

try
{
 OutboundShipmentController oOutboundShipmentController = new OutboundShipmentController();
 using (SharedDbConnectionScope scope = new SharedDbConnectionScope(oUser.ConnectionString))
 {
  OutboundShipment oOutboundShipment = OutboundShipment.FetchByID(nOutShipId);
  oOutboundShipment.ConsigneeId = dConsigneeId; // valid value
  oOutboundShipment.OutAddrId = dOutAddrId; // value that violates a constraint
  oOutboundShipment.OutContactId = dOutContactId; // valid value
  oOutboundShipment.Save(); // valid values are updated to the database
 }
}
catch (Exception ex)
{
    // constraint violation is not caught here
 WriteError(ex, this.oUser, "Application", "UpdateOutboundShipment");
}