Author Topic: [SOLVED] C# API equivalent to Repository.Execute  (Read 5650 times)

jan.izyk

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
[SOLVED] C# API equivalent to Repository.Execute
« 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
« Last Edit: November 07, 2015, 12:02:10 am by jan.izyk »

qwerty

  • EA Guru
  • *****
  • Posts: 13551
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: C# API equivalent to Repository.Execute
« Reply #1 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.
« Last Edit: November 06, 2015, 10:49:14 pm by qwerty »

jan.izyk

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C# API equivalent to Repository.Execute
« Reply #2 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.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: C# API equivalent to Repository.Execute
« Reply #3 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
My theories are always correct, just apply them to the right reality.

jan.izyk

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: C# API equivalent to Repository.Execute
« Reply #4 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.