Author Topic: diagram.Update() vs repository.SaveDiagram(diagramID) ?  (Read 3762 times)

mateiacd

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
diagram.Update() vs repository.SaveDiagram(diagramID) ?
« on: June 11, 2021, 11:23:26 pm »
Hi

EA.Repository rep = ...; initialized before
EA.Diagram dia = rep.GetCurrentDiagram();

//dia.Update() or rep.SaveDiagram(dia.DiagramID) ?

Is there any difference between the two ?
Both  should save the diagram to the database, hence no difference ?
« Last Edit: June 11, 2021, 11:41:59 pm by mateiacd »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: diagram.Update() vs repository.SaveDiagram(diagramID) ?
« Reply #1 on: June 11, 2021, 11:59:03 pm »
I would think so. Not unusual for EA to have duplicate operations doing the same with differend names/parameters. The Save in contrast to update would include manual user changes. Depends on whether the user had a chance to touch the diagram while your script ran.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: diagram.Update() vs repository.SaveDiagram(diagramID) ?
« Reply #2 on: June 12, 2021, 02:10:07 am »
- SaveDiagram saves the current unsaved (user) changes to the database.
- Diagram.Update() saves the changes made by your code to the database.

They are definitely not interchangeable

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: diagram.Update() vs repository.SaveDiagram(diagramID) ?
« Reply #3 on: June 12, 2021, 08:25:08 am »
Geert is right. I ran a short test:
Code: [Select]
d = rep.GetCurrentDiagram()
d.name="test"
rep.savediagram(d.diagramid)
The name was not changed. I wouldn't have been astonished if it had, though.

q.