1. OG data type - DataRow

    Article: AN0001678Updated: 20.10.2018

    This object represents one record in a class or query. You can use also its instances OGActualDatarow or OGOldDatarow in the respective context (e.g. in a rule).

    Object properties

    Name Description
    int Id Record Id.
    int ParentId Id of a class or query.
    ClassDefEntityType ParentType Type of the record owner - class or query.
    string ShortDescription Short description of the record.
    string FullId Full record Id. It contains class/query Id and record Id. This Id is used as an identifier in URL.
    bool IsNew Indication, wheather the record is new (not saved). If Id = 0, then the record is not saved.
    bool IsDeleted Indication, wheather the record is deleted. If there is a value in the column Deleted, than the record is deleted.
    Audit properties
    string Creator Account of the user that created the record.
    DateTime? Created Date of the record creation.
    DateTime? Modified Date of the last change of the record.
    string Modifier Account of the user that changed the record the last time.
    DateTime? Deleted Date of the record deletion.
    string Deleter Account of the user that deleted the record.
    int? CreatedDataSourceId Id of the data source at record creation.
    string CreatedDataSourceText Name of the data source at record creation.
    int? ModifiedDataSourceId Id of the data source at the last record change.
    string ModifiedDataSourceText Name of the data source at the last record change.
    int? DeletedDataSourceId Id of the data source at the record deletion.
    string DeletedDataSourceText Name of the data source at the record deletion.
    int? ArchiveId Id of the record in the archive table.
    string ArchiveUser Account of the user that archived the record (changed it or deleted it in the operational table).
    DateTime? ArchiveDate Date of the record archiving.
    Other functions and properties
    void AddNewComment(int columnClassDefId, string newComment, DataRow drOld) This method adds a new comment to a column of the type Long text with set property LongTextIsCommented = true.
    void ClearColumn(int columnId) This method sets the value for column to NULL. After saving into the database the column is deleted.
    void ClearColumn(string code) This method sets the value for column to NULL. After saving into the database the column is deleted.
    ColumnClassDef FindColumn(string code) Function finds a column in the class to which the record belongs (according to ParentId and ParentType).
    void RemoveColumn(int columnId) This method deletes the column from DataRow instance. After saving into the database the column is not impacted.
    void RemoveColumn(string code) This method deletes the column from DataRow instance. After saving into the database the column is not impacted.
    void RemoveColumnsExceptThose(string codes)

    This method clears all columns in the DataRow instance, except for the input columns. After saving in the database teh column will not be changed.

    Separate particular column codes with comma.

    EntityInfo ToEntityInfo()

    Function creates a new object EntityInfo and after that fills in properties:

    EntityInfo.Id = Id

    EntityInfo.DisplayName = ShortDescription

    string ListUrl URL to the list of records of the current class or query.
    string DetailUrl URL to the record detail of the current class or query.
    string NewDetailUrl URL to the detail of a new record of the current class or query.
    Functions for reading data from columns
    object GetColumnData(int columnId) Function reads value from the input column. Returned data type depends on the column type.
    string GetText(int columnId) Function returns text for column of the type short text.
    int? GetClassDef(int columnId) Function returns integer, representing Id of the class for column of the type Reference to a class.
    int? GetColor(int columnId) Function returns integer representing colour for the column of the data type Colour.
    string GetServerImage(int columnId) Function returns text, picture url, for the column of the type picture.
    string GetServerImageAsString(int columnId) Function returns text, picture url, for the column as text.
    int? GetInteger(int columnId) Function returns integer for the column.
    double? GetDouble(int columnId) Function returns decimal for the column.
    DateTime? GetDateTime(int columnId) Function returns date for the column.
    int? GetClassLink(int columnId) Function returns Id to the referred record for the column.
    EntityInfo GetXClassLink(int columnId) Function returns EntityInfo for column.
    string GetXClassLinkAsString(int columnId) Function returns EntityInfo for column as text.
    PersonInfo GetPerson(int columnId) Function returns PersonInfo for the column.
    bool? GetBoolean(int columnId) Function returns indication Yes/No for the column.
    Guid? GetGuid(int columnId) Function returns Guid for the column.
    EntityInfoList GetMultiClassLink(int columnId) Function returns list of EntityInfo for column that is a multiple reference to another class.
    EntityInfoList GetXMultiClassLink(int columnId) Function returns list EntityInfoList for column multiple reference to various classes.
    PersonInfoList GetMultiPerson(int columnId) Function returns list of PersonInfo for column that is a multiple reference to a user.
    string GetClassLinkAsString(int columnId) Function returns Id to the referred record for column as a text.
    string GetTextAsString(int columnId) Function returns text for column as a text.
    string GetLongTextAsString(int columnId, int maxLength) Function returns text for column as a text. If the length is greater as in parameter maxLength, text is trimmed to this max. length.
    string GetIntegerAsString(int columnId, string format) Function returns integer for column as text with defined format.
    string GetDoubleAsString(int columnId, string format) Function returns decimal for column as text with defined format.
    string GetDateTimeAsString(int columnId) Function returns date for column as a text.
    string GetDateTimeAsString(int columnId, DateTimeType dateTimeType) Function returns date for column as a text with defined format.
    string GetDateTimeAsString(int columnId, string format) Function returns date for column as a text with defined format.
    string GetBooleanAsString(int columnId) Function returns indication Yes/No for column as text according to the set localization.
    string GetGuidAsString(int columnId) Function returns Guid for column as text.
    string GetClassDefAsString(int columnId) Function returns integer representing class Id for column as text.
    string GetColorAsString(int columnId) Function returns integer representing colour for column as text.
    string GetColumnDataAsString(int columnId, ColumnType type) Function returns value of the column as text.
    object GetSystemColumnData(string dBColumnName) Function returns value of a system column.
    string GetSystemColumnDataAsString(string dBColumnName) Function returns value of a system column as text.
    object GetDR(string path) Function returns object according to the input path.
    object GetDR(string path, DbTransaction trans) Function returns object according to the input path.
    Functions for saving data in columns
    void SetColumnData(int columnId, ColumnType type, object value) This method sets the value of the column.
    void SetText(int columnId, string value) This method sets the value of the column of the type short text.
    void SetClassDef(int columnId, int? value) This method sets the value of the column of the type reference to a class.
    void SetColor(int columnId, int? value) This method sets the value of the column of the type colour.
    void SetServerImage(int columnId, string value) This method sets the value of the column of the type picture.
    void SetInteger(int columnId, int? value) This method sets the value of the column of the type integer.
    void SetDouble(int columnId, double? value) This method sets the value of the column of the type decimal.
    void SetDateTime(int columnId, DateTime? value) This method sets the value of the column of the type date.
    void SetClassLink(int columnId, int? value) This method sets the value of the column of the type value from a referenced class.
    void SetClassLink(int columnId, double? value) This method sets the value of the column of the type value from a referenced class.
    void SetXClassLink(int columnId, EntityInfo value) This method sets the value of the column of the type value from a referenced class to multiple classes.
    void SetPerson(int columnId, PersonInfo value) This method sets the value of the column of the type value from a referenced class (reference to user).
    void SetBoolean(int columnId, bool? value) This method sets the value of the column of the type indication Yes/No.
    void SetGuid(int columnId, Guid? value) This method sets the value of the column of the type guid.
    void SetMultiClassLink(int columnId, EntityInfoList value) This method sets the value of the column of the type multiples reference to class data.
    void SetMultiPerson(int columnId, PersonInfoList value) This method sets the value of the column of the type multiples reference to users.
    void SetClassLinkAsString(int columnId, string value) This method sets the value of the column of the type value from a referenced class as a text. This value is not saved in the database and is used only for display on pages for the user.
    void SetMultiXClassLink(int columnId, EntityListBase value) This method sets the value of the column of the type multiple values from a referenced class to multiple classes.

    Reading column data

    There are many fucntions for reading data from column according to the column type. However, if you need just a text value that you will only display and not use it further, you can use method GetColumnDataAsString for user-defined columns and GetSystemColumnDataAsString for system columns. Information if the column is user-defined or system one can be found in the object ColumnClassDef in the property IsSystemColumn.

    Look at a detailed description of data types for reading and writing.

    Writing data into columns

    There are many functions for writing data into columns. There is at least one function for each type of column.

    However, you can use one universal method SetColumnData for writing in all the columns. Nevertheless, you have to take care of the inserted data type that has to correspond with the column type.

    Look at a detailed description of data types for reading and writing.

    Universal write and read

    A simplified syntax can be used ror writing and reading data from the object. In order to use this syntax you have to know column code or column ID.

    var x = dr[column_id];
    dr[column_id] = ...

    var x = dr['code'];
    dr['code'] = ...

    Column code can be simple 'kod' or compound 'kod_tridy.kod_sloupce'.  Use the simple code, if you query column, belonging to the same class that is in the property ParentId of DataRow, that you use. use the compound column for query from a parent record.

    This syntax does not work for columns of type File.

    Note: These function Funkce use internally functions GetColumnData and SetColumnData.

    Function GetDR

    Function GetDR enables a comfortable navigation between references of particular records without complicated filter creation, data reading etc.

    E.g. lets have an instance DataRow of class School. This class has a reference to City and City has a reference to Country. If you wanted to read the country from the datarow of the class school, you would have to perform two searches (city and then country). By means of GetDR function everything can be get faster:

    var country = drSchool.GetDR('city>country');

    Parameter path contains all the columns over which it should pass. The first one is column city from the class School. This will identify record from the class City. Then there is column code country from the class City, which will identify record in the class Country. And this record will be returned by the function. If some of columns is not filled in, NULL is returned.

    All the columns except for the last one has to be a simple reference.

    If you configured class extending user properties in your ObjectGears instance, then you can pass also over person record. If it is not configured, then user referece can be only the last parameter in the function.

    Pro procházení lze zase použít příkaz FOR.

    var drLinky = dr.GetDR('nasobny sloupec');

    for( var i = 0; i < drLinky.Count; ++i)
    {
      var id = drLinky[i].Id;
      var text = drLinky[i].ShortDescription;
    }

    Text columns

    You can use functions GetText, SetText a GetTextAsString for text. Function GetLongTextAsString( int column, int maxLength) can be used for column long text. This function returns text in the input max length.

    Function FindColumn

    Column code can be defined in two ways in the function FindColumn:

    column_code - column code itself. The column will be than searched directly in the class/query that are represented by the property ParentId of DataRow.

    column_code.class.code - class code followed by column code. The column will be than searched in a parent class that has code class_code.

    Audit of the record

    ObjectGears system distinguishes two levels of logging changes and auditing. One is directly in the object DataRow and it is represented by six audit columns (Created, Creator,...), that keep information who and when created the record, changed it the last time and deleted it.

    If you need more details you can switch on archiving in the class. After that all the changes are recorded in the archive table in form of record versions. Such records have filled in columns ArchiveId, ArchiveUser and ArchiveDate.

    Comments

    It is possible to activate comment mode for column of the type Long text. After that you can add new comments to the overall text also from programs by means of method  AddNewComment. There is a separator, date and name of the user, that added the comment, placed in front of each comment. If the record does not have any comment yet, this "heading" is not inserted.

    This property is useful for fields, that you do not want change and just need to add new comments, changes etc. (e.g. logs)

    ----- 09.09.2013 09:44:27 - Adam Smith
    New comment.
    -----
    The first comment. There is only couple of dash signs added in front of it for separation.

×