/// <summary> /// Converts the given <paramref name="dto"/> to a new model object, deleting the entity first if it already exists. /// </summary> public TModelObject ConvertReplacingExisting(TDtoObject dto, [NotNull] string id, ITransactionDataAccess dataAccess) { var modelObject = dataAccess.GetItem <TModelObject>(id) ?? CreateModelInstance(dto); modelObject.Id = id ?? throw new ArgumentNullException(nameof(id)); Convert(dto, modelObject); return(modelObject); }