ObjectGears Help

           
Forum   ObjectGears (Version: 1.6.0.0)

OG data type - DataRow

This object represents one record in a class or query.

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 RemoveColumn(int columnId) This method deletes the column from DataRow instance. After saving into the database the column is not impacted.
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<EntityInfo> GetMultiClassLink(int columnId) Function returns list of EntityInfo for column that is a multiple reference to another class.
EntityInfoList<EntityInfo> 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.
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<EntityInfo> 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<EntityInfo> 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.

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.

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.

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.

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.

This website is using cookies files to provide services and analyse visits. You agree with that by using this website.     Further information