The following returns an empty array:
var sdnoRow = sdnoColumn.Lookup(channel.Label);
However, the following returns true:
sdnoColumn.GetValue("31793.0.31794").Equals(channel.Label)
Have I misunderstood what Lookup() is supposed to do?
EDIT: More context added
var dms = protocol.GetDms();
var sdnoV2 = dms.GetElement(new DmsElementId(127701, 250));
var sdnoDestinationsTable = sdnoV2.GetTable(1300);
IDmsColumn<string> sdnoColumn = sdnoDestinationsTable.GetColumn<string>(1302);foreach (var channel in channels)
{
var sdnoRow = sdnoColumn.Lookup(channel.Label);
...
}
I ended up using IDmsTable.QueryData() instead.
Hi Robin,
I just verified: the Lookup method uses the Notify GetKeysForIndex.
This notify requires the lookup-column to be indexed (e.g. via ;indexColumn option) so the search can happen.
https://docs.dataminer.services/develop/api/types/Skyline.DataMiner.Scripting.SLProtocol.GetKeysForIndex.html
I would personally avoid using this method as you would need to update the other driver(s).
Instead you could use QueryData(filter)
https://docs.dataminer.services/develop/api/types/Skyline.DataMiner.Library.Common.IDmsTable.QueryData.html
For example, this is used in one of our Tests:
IDms dms = new Dms(communication);
IDmsElement element = dms.GetElement(Settings.TestElementName);
IDmsTable table = element.GetTable(exampleTableId);List<ColumnFilter> filter = new List<ColumnFilter>();
filter.Add(new ColumnFilter { Pid = exampleTableId + 2, Value = "DK Row 1", ComparisonOperator = ComparisonOperator.Equal });foreach (object[] row in table.QueryData(filter))
{
if (row == null || row.Length < 6)
{
hasUnknown = true;
break;
}string pk = Convert.ToString(row[0]);
string dk = Convert.ToString(row[1]);
string textVal = Convert.ToString(row[2]);
int intVal = Convert.ToInt32(row[3]);
double doubleVal = Convert.ToDouble(row[4]);
DateTime dtVal = DateTime.FromOADate(Convert.ToDouble(row[5]));
}
Hi Robin,
The purpose of the Lookup is to search 1 or multiple values in a specific column and return the primary keys of all the rows where those values could be found.
Would it be possible to share a bit more of the code? So we can verify everything is correctly initialized?
Sure thing! See EDIT for more context.