DataCollection


Object Hierarchy:

Vda.DataCollection Vda.DataCollection Vda.DataCollection GLib.Object GLib.Object GLib.Object->Vda.DataCollection

Description:


public interface DataCollection : Object

Implementators will be able to execute a SELECT to get all objects in the database related to a parent object.

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

// Database mapping
[Description (nick="@id::pkey::auto")]
public int id { get; set; }
[Description (nick="@street")]
public string street { get; set; }
[Description (nick="@client::id")]
public int client { get; set; }
construct {
database_table_name = "address";
}
}
public class Addresses : Object, Vda.DataCollection {
private string _parent_property;
private DataObject _parent;
private GLib.Type _object_type;
private string _ref_field;

public Vda.Connection database_connection { get; set; }
public string parent_property { get { return _parent_property; } }
public DataObject parent { get { return _parent; } }
public GLib.Type object_type { get { return _object_type; } }
public string ref_field{ get { return _ref_field; } }
public Cancellable cancellable { get; set; }

construct {
_parent_property = "id";
_ref_field = "client";
_object_type = typeof (Address);
}

public Addresses (Client client) {
_parent = client;
}
}

public class Client : Object, Vda.DataObject {
Vda.Connection _cnc = null;
// DataObject
public string database_table_name { get; construct set; }
public Vda.Connection database_connection {
get {
return _cnc;
}
set {
_cnc = value;
addresses.database_connection = _cnc;
}
}
public Cancellable cancellable { get; set; }

// Database mapping
[Description (nick="@id::pkey::auto")]
public int id { get; set; }
[Description (nick="@name")]
public string name { get; set; }
[Description (nick="@description")]
public string description { get; set; }
[Description (nick="@phone::id")]
public string phone { get; set; }
public Addresses addresses { get; set; }

construct {
database_table_name = "clients";
addresses = new Addresses (this);
}
}

Using the above code a query, by accessing the Addresses object, you can call get_objects and a the following query will be executed:

SELECT * FROM address WHERE address.client = 100;

Above number 100, is calculated from the current instance of Client object's id property.


Namespace: Vda
Package: vda-1

Content:

Properties:

Methods:

Inherited Members:

All known members inherited from class GLib.Object



2022 vala-language.org