0
我正在使用AutoMapper並嘗試從另一個對象更新我現有對象的屬性。 兩個對象都是相同的類型。但是,當我在一個已存在的對象上使用automapper時,它變成了一個新的對象,因此它的引用正在被破壞。所以我必須手動完成所有這些,試想一下,如果我在對象上有100個屬性。AutoMapper是否能夠更新對象
originalWell.AngularLatitudeDegrees1 = updatedWell.AngularLatitudeDegrees1;
originalWell.AngularLatitudeMinutes1 = updatedWell.AngularLatitudeMinutes1;
originalWell.AngularLatitudeSeconds1 = updatedWell.AngularLatitudeSeconds1;
originalWell.AngularLongitudDegrees1 = updatedWell.AngularLongitudDegrees1;
originalWell.AngularLongitudMinutes1 = updatedWell.AngularLongitudMinutes1;
originalWell.AngularLongitudSeconds1 = updatedWell.AngularLongitudSeconds1;
我嘗試這是
AutoMapper.Mapper.CreateMap<Well,Well>();
originalWell = AutoMapper.Mapper.Map<Well>(udpatedWell);
非常感謝,工程就像一個魅力。 – MegaMind