i'am a problem. I use DevArt DotConnect for MySQL 6.30 (latest release).
When i call:
Code: Select all
public void UpdateCarOptionals(List listCodGlo, Int64 idCar)
{
List listToDelete = this.GetCarOptionals(idCar).ToList();
foreach (var item in listToDelete)
{
m_Model.AbCarsOptionals.DeleteOnSubmit(item);
}
foreach (String codGlo in listCodGlo)
{
AbCarsOptional optToAdd = new AbCarsOptional();
optToAdd.IdCar = idCar;
optToAdd.CodGlo = codGlo;
m_Model.AbCarsOptionals.InsertOnSubmit(optToAdd);
}
m_Model.SubmitChanges();
}
Code: Select all
Message: Cannot remove an entity that has not been attached.
Source: Devart.Data.Linq
StackTrace: at Devart.Data.Linq.Table.b(Object A_0, MetaType A_1, Dictionary`2 A_2, Boolean A_3)
at Devart.Data.Linq.Table.b(Object A_0, Boolean A_1)
at Devart.Data.Linq.Table`1.DeleteAllOnSubmit[TSubEntity](IEnumerable`1 entities)
at AutoCore.Models.CommonRepository.UpdateCarOptionals(List`1 listInc, Int64 idCar)
at AutoCore.Models.CommonRepository.EditCarMainData(AbCar carToUpdate, Int32 codMar, Int32 codMod, Int32 codAll, Int16 idColor, Int32 mileage, Int16 regYear, Byte regMonth, Boolean metalyzed, Int16 purchaseYear, Byte purchaseMonth, Int16 genSat)
at AutoWeb.Controllers.GarageController.CarEditMainDataSave(GarageEditMainDataViewModel gceMdVm)
CREATE TABLE `ab_cars_optionals` (
`Id` bigint(20) NOT NULL AUTO_INCREMENT,
`IdCar` bigint(20) NOT NULL COMMENT 'rif.auto',
`CodGlo` varchar(5) NOT NULL COMMENT 'codice optional normalizzato',
PRIMARY KEY (`Id`),
UNIQUE KEY `IdGarageCodGloUX` (`IdCar`,`CodGlo`),
KEY `FK_ab_cars_optionals_ice_normalized_registries` (`CodGlo`),
CONSTRAINT `FK_ab_cars_optionals_cars` FOREIGN KEY (`IdCar`) REFERENCES `ab_cars` (`Id`) ON UPDATE CASCADE,
CONSTRAINT `FK_ab_cars_optionals_ice_normalized_registries` FOREIGN KEY (`CodGlo`) REFERENCES `ice_normalized_registries` (`CodGlo`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8
Can you help me?
Best regards.