Irwsoft Data Framework

Insert a New Record into Relation Data-schema
Brief Information
EditionsAll Editions
TopicsInsert records into 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.

This sample will show how to insert a record/s into Table object of relation data-schema.

Example : insert a new member record 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);

// Declare and initiate a new instance PersonTable.
PersonTable newMember = new PersonTable();

// Set all Column properties with data to be inserted
newMember.FirstName.Value = "NewPerson";
newMember.Status.Value = true;
// Set the LeaderId of member with value of PersonId of Andy.
// it will be set automatically by specifying keyColumnsCheck parameter to true.

newMember.LeaderId.Value = pAndy.PersonId.Value;  // [OPTIONAL]

// Adds the new member to Members property of Andy.

// Now call Insert method to insert all added rows.
// NOTE : since we already set all foreign key columns with correct value, set keyColumnsCheck parameter to false.
//        if you set keyColumnsCheck parameter to true, it will slower the insertion.


Related Topics :

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