0

When adding records to a set, the resulting keys variable contains only one empty string, instead of the expect "i1".

var workspace = new GAMSWorkspace("TestWorkspace");
var database = workspace.AddDatabase();
var set = database.AddSet("TestSet", 1);
var record = set.AddRecord("i1");
var keys = record.Keys;
database.Export("TestDb");

What can cause this problem running the version Assembly GAMS.net4, Version=28.2.0.0

When I export the database to a .gdx file, the set contains the element i1.

jasdefer
  • 757
  • 12
  • 24

1 Answers1

0

How did you check, that the keysvariable does not contain the expected string? The record.Keys property returns a string[]. And if I add a WriteLine to your example, I get the expected string:

var database = ws.AddDatabase();
var set = database.AddSet("TestSet", 1);
var record = set.AddRecord("i1");
var keys = record.Keys;
Console.WriteLine(keys[0]);

Output:

i1
Lutz
  • 2,197
  • 1
  • 10
  • 12
  • I checked it the same way you did. But the output is always `""`. Which api version are you using? – jasdefer Oct 07 '19 at 07:55
  • I used 28.2.0.0 (from C:\GAMS\win64\28.2\GAMS.net4.dll). So I guess, it is the same you used? – Lutz Oct 07 '19 at 08:30
  • Yes, so I guess I have some problems with my system setup. – jasdefer Oct 07 '19 at 08:36
  • Might be. But it is strange, that things seem to work in general, so that you get the expected element in the set after exporting to GDX. I do not have a good explanation for this at the moment – Lutz Oct 07 '19 at 08:50