/// <summary> /// Populates collections within table. The tables used will be removed from /// the table collection. /// Override this method to populate your custom collection objects. /// </summary> /// <param name="tables">The tables.</param> /// <param name="filter">The filter.</param> protected override void PopulateCollections(DataTableCollection tables, string filter) { base.PopulateCollections(tables, filter); // Populate object collections DataView view = DataHelper.CreateDataView(tables["OrderForm"], filter); // Read until we are done, since this is a collection foreach (DataRowView row in view) { // Populate Forms Collection OrderForm orderForm = (OrderForm)OrderContext.Current.OrderFormClassInfo.CreateInstance(); orderForm.Load(row); orderForm.PopulateCollectionsInternal(tables, filter); OrderForms.Add(orderForm); } view = DataHelper.CreateDataView(tables["OrderGroupAddress"], filter); foreach (DataRowView row in view) { // Populate Address Collection OrderAddress orderAddress = (OrderAddress)OrderContext.Current.OrderAddressClassInfo.CreateInstance(); orderAddress.Load(row); OrderAddresses.Add(orderAddress); } }
/// <summary> /// Accepts the changes. /// </summary> public override void AcceptChanges() { using (TransactionScope scope = new TransactionScope()) { // Save base object first base.AcceptChanges(); if (this.ObjectState != MetaObjectState.Deleted) { // Populate object primary key here // Save forms OrderForms.AcceptChanges(); // Save addresses OrderAddresses.AcceptChanges(); } scope.Complete(); } }
/// <summary> /// Marks current instance as new which will cause new record to be created in the database for the specified object. /// This is useful for creating duplicates of existing objects. /// </summary> internal override void MarkNew() { base.MarkNew(); OrderAddresses.MarkNew(); OrderForms.MarkNew(); }
/// <summary> /// Sets the parent. /// </summary> /// <param name="parent">The parent.</param> public override void SetParent(object parent) { OrderAddresses.SetParent((OrderGroup)parent); OrderForms.SetParent((OrderGroup)parent); }