Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: jan.izyk on November 06, 2015, 10:27:01 pm

Title: [SOLVED] C# API equivalent to Repository.Execute
Post by: jan.izyk on November 06, 2015, 10:27:01 pm
Hi all,

I've got again a question about the C# API of EA.

With the command
Code: [Select]
myRepository.SQLQuery(...)I can execute select-statements to the database.
But with this function I can't execute something like insert-into statements.

But at the scripting-interface there is the function Repository.Execute which can execute insert-into statements.

So my question is:
Is there any possibility to execute insert-into/update/... statements via the C# API like in the scripts?

Regards
Jan
Title: Re: C# API equivalent to Repository.Execute
Post by: qwerty on November 06, 2015, 10:48:38 pm
As you said: Repository.Execute. This is completely undocumented and unsupported and misuse of it can damage your repository. Know what you are doing! And no question: you will not get any support for it from Sparx.

q.
Title: Re: C# API equivalent to Repository.Execute
Post by: jan.izyk on November 06, 2015, 11:13:24 pm
Hi querty,

thanks for your reply.

Now I have seen the Execute-function in the interface  IDualRepository.
But I can't get access to this function when myRepository is from type
EA.Repository.

So do you know, how I can get access to this function?

And thanks for the hint. I know, that it is dangerous to change the database directly. But sometimes it has to be done by this way.
Title: Re: C# API equivalent to Repository.Execute
Post by: Uffe on November 06, 2015, 11:44:02 pm
Hi Jan,

Just go ahead and call Repository.Execute(). The code will compile and run perfectly fine.

/Uffe
Title: Re: C# API equivalent to Repository.Execute
Post by: jan.izyk on November 07, 2015, 12:01:40 am
Outsch. Now I've got it.

In the autocompletition-window in Visual Studio, the function isn't seen.

I have to execute it with MY repository and not as a static function Execute of the Namespace Repository.

As a small example-function for everyone who doesn't have a clue like me
Code: [Select]
void executeSqlStatement(EA.Repository myRepository, string mySqlStatement)
{
  myRepository.Execute(mySqlStatement);
}

Thanks to you q and Uffe.