Book a Demo

Author Topic: C# SDK - How do you access IDs greater than 32767  (Read 7315 times)

IanG

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
C# SDK - How do you access IDs greater than 32767
« on: August 14, 2017, 06:59:27 pm »
Hello,

I'm writing an extension for EA in C# using.

Normally, when I want to access a model in the repository I use the following:
Code: [Select]
EA.Package MyPackage = (EA.Package)m_Repository.Models.GetAt(MyShort);

However, the the repository I'm working with has over 41,000 models.
The GetAt method only takes a short which is a problem since shorts are 16bit and only go to 32767. (unsigned shorts don't work.)

Has anyone else come across this problem and know of a solution?

Cheers,

Ian 

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: C# SDK - How do you access IDs greater than 32767
« Reply #1 on: August 14, 2017, 08:23:33 pm »
Hi Ian,

Are you sure you've actually got 41,000 models? In this context, "model" means "root node" -- not package.
I'm pretty sure no EA.Collection can contain more than 32,767 objects.

/Uffe
My theories are always correct, just apply them to the right reality.

IanG

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: C# SDK - How do you access IDs greater than 32767
« Reply #2 on: August 14, 2017, 09:16:24 pm »
The model doesn't have more than 41,000 models but the ID numbers definitely exceed 32767.
I'm working with a copy of  a live eap file that has had the majority of the content removed.

I've uploaded a screen shot with the contents of the diagramobjects table so you can see.


I'm assuming that with elements being deleted and created over time has inflated the ID number. But that's only a guess, I'm not sure why that should be.

I can't do a for loop since and look for a match either since it's not enumerable. Hmmmmm

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: C# SDK - How do you access IDs greater than 32767
« Reply #3 on: August 14, 2017, 09:20:28 pm »
In what age do you live to access database ids with 16 bit?

q.

IanG

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: C# SDK - How do you access IDs greater than 32767
« Reply #4 on: August 14, 2017, 10:04:46 pm »
Indeed,

But the 16bit constraint is not one I've made, it's how the Enterprise Architect SDK is setup.
The Models.GetAt() method takes a short to represent the ID. It won't accept any other type, ushort, long, int etc.



I can get at the data as xml with an SQL command but I want to be able to retrieve the EA package object.

Cheers,
Ian


Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: C# SDK - How do you access IDs greater than 32767
« Reply #5 on: August 14, 2017, 11:01:07 pm »
Collection.GetAt() takes an index -- not an ID.

Can you please confirm that your project has more than 32,767 root nodes?

/U
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: C# SDK - How do you access IDs greater than 32767
« Reply #6 on: August 14, 2017, 11:10:51 pm »
As Uffe said...

However, such limitations from planet Sparx are not an exception but the default :-(

q.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: C# SDK - How do you access IDs greater than 32767
« Reply #7 on: August 18, 2017, 11:31:29 am »
Collection.GetAt() takes an index -- not an ID.

Can you please confirm that your project has more than 32,767 root nodes?

Uffe is correct here. GetAt() takes an index, not an ID. If you want to get a specific package by it's ID, use Repository.GetPackageByID( long ).

Eamonn John Casey

  • EA User
  • **
  • Posts: 110
  • Karma: +0/-1
    • View Profile
Re: C# SDK - How do you access IDs greater than 32767
« Reply #8 on: August 18, 2017, 06:37:16 pm »
It may be better to use the SQLQuery first and then iterate through that:

Code: [Select]
String strResult =
eaRepository.SQLQuery("SELECT ea_guid FROM ...");

List<Row> rows = EAGuid.Deserialise(strResult);