Article: AN0001599Updated: 20.10.2018
The below table displays list of data types for reading and writing from object DataRow for various column types. In order to write data we can use more data types depending on what we have at disposal.
Example for reading values:
var value = dr['column_code'];
Example for writing values:
dr['column_code'] = value;
Question mark indicates that the column can be null (can contain NULL value).
Column type Value from referenced class
When reading value from a multiple classlink instance of the collection EntityInfoList nebo PersonInfoList is ALWAYS returned - even in case of an empty column.
There is id of the referenced record in the value Id for Classlink in EntityInfo.
There is id of the referenced record in the value Id and id of the target class in the value ParentId for XClasslink in EntityInfo.
There is id of a user in the value Id and full name of the user in the value DisplayName for reference to a user in PersonInfo.
Work with multiple references
You can go through the collection by means of cycle FOR.
var links = dr['multiple_column'];
for( var i = 0; i < links.Count; ++i)
{
var id = links[i].Id;
var text = links[i].DisplayName;
}
You can find the entty in the collection by means of method GetById( int id).
var link = linky.GetById(100); //100 je zde ID záznamu
You can delete the link by some of the Remove methods..:
RemoveById(int id, bool duplicityId)
linky.RemoveById(100, true);
Set the parameter duplicityId as true, if the collection can have duplicate occurence of one ID. Otherwise, use false.
RemoveAt(int index)
links.RemoveAt(3); //deletes item on position 3
Remove(item)
links.Remove( linky[1]); //deletes item on position 1
In order to add or remove reference it is necessary save the given dr (record DataRow), e.g.:
OG.DataRow.SaveData(dr);
This function can save a collection of records DataRow, either at once in collection or one by one.
OG.DataRow.SaveData(DataRowList dataRowList, bool allInTransaction);
Function List GetIds() provides list of ID in the given collection. They can then be used in other functions.
var ids = linky.GetIds();
Other functions for EntityInfoList and PersonInfoList.
int GetMaxId() - provides MAX ID in the collection
int GetMinId() - provides MIN ID in the collection
bool IsAnyItemNull() - function returns true, if some item in the collection is null. Otherwise false is returned.
int Count - number of items in the collection
Collection PersonInfoList has also function bool Contains(int personId), which determines whether there is user of the given ID in the collection.
var exist = dr['persons'].Contains(100); //returns true, if there is user with ID 100 in the multiple column
In order to get full DataRow objects from a simple or multiple classlink use function GetDR.
var drLinks = dr.GetDR('multipleclasslinks');
System columns
System columns are read-only. They are updated by the system.
Question mark indicates that the column can be null (can contain NULL value).