DataObject


Object Hierarchy:

Vda.DataObject Vda.DataObject Vda.DataObject GLib.Object GLib.Object GLib.Object->Vda.DataObject

Description:


public interface DataObject : Object

Represent managable row data in a Table in the database.

Properties should have its nick in the form '@field_name::id' where 'field_name' is the name of your field in the database's table, supporting any case, including spaces. '@' is just a mark to detect the property as one to be mapped to a database's table's field. '::id' should be added only on properties containing an ID to get data from database.

In order to be able to execute operations over the database, you should set database_connection with the connection to the databae and database_table_name to the table's name in the database to execute operations over.

If more than one property with a nickname using a '::id' suffix is located, the object takes the actual value of each property to create a filter condition with an AND operator as the form 'field_name = property_value AND field_name2 = property_value2'

In the following example, the properties name, phone and email, are used to store data from the database when update_data_from_db is called.

If you try to retrive data from the database, first you should set the properties phone and email, in the example bellow, then call update_data_from_db, this will ejecute a SELECT query using a WHERE condition in the form "phone = 'phonevalue' AND email = 'emailvalue' " as a filter that should return just one row.

Once you have the data from any source, like calling update_data_from_db, is possible to update any property then call update_data_into_db to UPDATE the data in the table's database.

When a new row is required, insert a row, set all the properties you want to insert with the row and then call insert_data_into_db. Mark a property with a nickname using a '::auto' suffix to ignore it in the hope it is automatically set by the database engine. In the example bellow, the country property is automatically set by the database engine, as a default value, for example.

  public class Client : Object, Vda.DataObject {
public string database_table_name { get; construct set; }
public Vda.Connection database_connection { get; set; }
public Cancellable cancellable { get; set; }

[Description (nick="@id::pkey::auto")]
public int id { get; set; }

[Description (nick="@name")]
public string name { get; set; }

[Description (nick="@phone::id")]
public string phone { get; set; }

[Description (nick="@email::id")]
public string email { get; set; }

[Description (nick="@country::auto")]
public string country { get; set; }
}


Namespace: Vda
Package: vda-1

Content:

Properties:

Static methods:

Methods:

Inherited Members: