public IQueryable <CI_Parent> GetParents() { return(CompositionInheritanceHelper.CreateCompositionHierarchy().AsQueryable()); }
/// <summary> /// Use the changeset composition APIs to navigate all child updates /// </summary> /// <param name="parent"></param> private void NavigateChildChanges(CI_Parent parent) { // if the parent has had property modifications, original will // be non-null if (this.ChangeSet.GetChangeOperation(parent) != ChangeOperation.Insert) { CI_Parent originalParent = this.ChangeSet.GetOriginal(parent); } // navigate all child changes w/o specifying operation type Dictionary <object, ChangeOperation> changeOperationMap = new Dictionary <object, ChangeOperation>(); foreach (CI_Child child in this.ChangeSet.GetAssociatedChanges(parent, p => p.Children)) { ChangeOperation op = this.ChangeSet.GetChangeOperation(child); changeOperationMap[child] = op; if (this.ChangeSet.GetChangeOperation(child) != ChangeOperation.Insert) { CI_Child originalChild = this.ChangeSet.GetOriginal(child); } if (op == ChangeOperation.None) { } else if (op == ChangeOperation.Insert) { CompositionInheritanceHelper.Assert(this.ChangeSet.ChangeSetEntries.SingleOrDefault(p => p.Entity == child && p.Operation == DomainOperation.Insert) != null, "Expected corresponding insert operation not found."); } else if (op == ChangeOperation.Update) { CompositionInheritanceHelper.Assert(this.ChangeSet.ChangeSetEntries.SingleOrDefault(p => p.Entity == child && p.Operation == DomainOperation.Update) != null, "Expected corresponding update operation not found."); } else if (op == ChangeOperation.Delete) { CompositionInheritanceHelper.Assert(this.ChangeSet.ChangeSetEntries.SingleOrDefault(p => p.Entity == child && p.Operation == DomainOperation.Delete) != null, "Expected corresponding delete operation not found."); } } // verify all child operations against the map we built up during enumeration // of associated changes to ensure all operations were returned foreach (ChangeSetEntry operation in this.ChangeSet.ChangeSetEntries.Where(p => p.Entity.GetType() != typeof(CI_Parent))) { switch (operation.Operation) { case DomainOperation.Insert: CompositionHelper.Assert(changeOperationMap.ContainsKey(operation.Entity) && changeOperationMap[operation.Entity] == ChangeOperation.Insert, "Expected insert operation was not returned from GetAssociatedChanges."); break; case DomainOperation.Update: CompositionHelper.Assert(changeOperationMap.ContainsKey(operation.Entity) && changeOperationMap[operation.Entity] == ChangeOperation.Update, "Expected update operation was not returned from GetAssociatedChanges."); break; case DomainOperation.Delete: CompositionHelper.Assert( changeOperationMap.ContainsKey(operation.Entity) && changeOperationMap[operation.Entity] == ChangeOperation.Delete, "Expected delete operation was not returned from GetAssociatedChanges."); break; } } // navigate all child changes specifying operation type foreach (CI_Child child in this.ChangeSet.GetAssociatedChanges(parent, p => p.Children, ChangeOperation.None)) { } foreach (CI_Child child in this.ChangeSet.GetAssociatedChanges(parent, p => p.Children, ChangeOperation.Insert)) { } foreach (CI_Child child in this.ChangeSet.GetAssociatedChanges(parent, p => p.Children, ChangeOperation.Update)) { } foreach (CI_Child child in this.ChangeSet.GetAssociatedChanges(parent, p => p.Children, ChangeOperation.Delete)) { } }