Irwsoft Data Framework

Select Records from Master or Child of a dataschema
Brief Information
EditionsAll Editions
TopicsRetrieve records from Master table or Child table of a dataschema.
RemarksA dataschema class can have relations to another dataschema as a master-table or a child-table. For more information about Relation Dataschema.

Before continue to the sample, you should know about :


Example : This sample want to display information about leader and members of a person.

  1. Get person record/object from previous select query.
  2. Display record of his leader from Person table, and
  3. Display records of his members from Person table which status is 'true' (available).
Previous Next

Leader of Andy

C# code
// continue from sample "Select Single Table",
// Execute the query and return DataView instance that provide properties and methods to access data

Irwsoft.Data.DataView dv = select.Execute();

// Extract PersonTable object of Andy into pAndy variable.
PersonTable pAndy = dv.GetDataSchemaObject<PersonTable>(person, 0);

// Invoke Select method of Leader property.
pAndy.Leader.Select();

// Here how to retrieve single data from a table to get leader name of Andy.
String name = pAndy.Leader.Rows[0][pAndy.Leader.DataSchema.FirstName].ToString();

Members of Andy

C# code
// continue from sample "Select Single Table",
// Execute the query and return DataView instance that provide properties and methods to access data

Irwsoft.Data.DataView dv = select.Execute();

// Extract PersonTable object of Andy into pAndy variable.
PersonTable pAndy = dv.GetDataSchemaObject<PersonTable>(person, 0);

// Here is the sample if you want to retrieve members of Andy which status is true.
// Note : You need to set where condition from its Where property of Members table,
//        before invoke Select method of Members table.
//        You can also using DataSchema and OwnerDataSchema properties for the condition.

pAndy.Members.Where.Compare(pAndy.Members.DataSchema.Status, ComparisonOperator.Equal, true);

// Invoke Select method of Members property.
pAndy.Members.Select();

// Here how to retrieve all data from Members table.
foreach (TableRow<T> row in pAndy.Members.Rows)
{
    foreach (Column column in pAndy.Members.ColumnSchema)
    {
        Console.WriteLine(row[column].ToString().PadLeft(20, " "));
    }
}

Related Topics :

Irwsoft Data Ultimate Edition provides comprehensive features of Irwsoft Data Framework and support from irwsoft.