1. Description of data types for reading and writing

    Artikel: AN0001599Aktualisiert: 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;

     

    Column type Reading values Writing values
    Text string string
    Integer int?

    int?

    double?

    Decimal double? double?
    Indication True/False bool? bool?
    Date DateTime? DateTime?
    Colour int?

    int?

    double

    Color

    Reference to a class int? int?
    Guid Guid? Guid?
    File files cannot be read in this way files cannot be written in this way
    Picture string string
    Value from a referenced class - simple to a class (Classlink) int?

    int?

    double

    DataRow

    Person

    string - value is converted to an integer and represents ID of a referenced record

    Value from a referenced class - multiple to a class (Classlink) EntityInfoList EntityInfoList
    Value from a referenced class - simple to a user PersonInfo PersonInfo
    Value from a referenced class - multiple to a user PersonInfoList PersonInfoList
    Value from a referenced class - simple to more classes (XClasslink) EntityInfo EntityInfo
    Value from a referenced class - multiple tomore classes (XClasslink) EntityInfoList EntityInfoList

    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. 

    Columns Reading values
    Id int
    Creator string
    Created DateTime?
    Modified DateTime?
    Modifier string
    Deleted DateTime?
    Deleter string
    ShortDescription string
    CreatedDataSourceId int?
    ModifiedDataSourceId int?
    DeletedDataSourceId int?

    Question mark indicates that the column can be null (can contain NULL value).

×