示例#1
0
        // expose an entity that is simultaneously both a parent and a child
        // we expect a public entity list and query method for the type
        public IEnumerable <SelfReferencingComposition> GetSelfReferencingCompositions()
        {
            List <SelfReferencingComposition> entities = new List <SelfReferencingComposition>();

            SelfReferencingComposition parent1 = new SelfReferencingComposition {
                ID = 1, Value = "A"
            };

            entities.Add(parent1);
            SelfReferencingComposition child1 = new SelfReferencingComposition {
                ID = 2, ParentID = 1, Parent = parent1, Value = "B"
            };

            parent1.Child = child1;
            entities.Add(child1);

            SelfReferencingComposition parent2 = new SelfReferencingComposition {
                ID = 3, Value = "C"
            };

            entities.Add(parent2);
            SelfReferencingComposition child2 = new SelfReferencingComposition {
                ID = 4, ParentID = 3, Parent = parent2, Value = "D"
            };

            parent2.Child = child2;
            entities.Add(child2);

            // parent with no children
            SelfReferencingComposition parent3 = new SelfReferencingComposition {
                ID = 5, Value = "C"
            };

            entities.Add(parent3);

            return(entities);
        }
示例#2
0
 public void CustomParentUpdate(SelfReferencingComposition sr)
 {
 }
示例#3
0
 public void Update(SelfReferencingComposition sr)
 {
 }
示例#4
0
 public void UpdateSelfReferencingComposition(SelfReferencingComposition entity)
 {
 }
 public void CustomParentUpdate(SelfReferencingComposition sr)
 {
 }
 public void Update(SelfReferencingComposition sr)
 {
 }
        public void UpdateSelfReferencingComposition(SelfReferencingComposition entity)
        {

        }
        // expose an entity that is simultaneously both a parent and a child
        // we expect a public entity list and query method for the type
        public IEnumerable<SelfReferencingComposition> GetSelfReferencingCompositions()
        {
            List<SelfReferencingComposition> entities = new List<SelfReferencingComposition>();

            SelfReferencingComposition parent1 = new SelfReferencingComposition { ID = 1, Value = "A" };
            entities.Add(parent1);
            SelfReferencingComposition child1 = new SelfReferencingComposition { ID = 2, ParentID = 1, Parent = parent1, Value = "B" };
            parent1.Child = child1;
            entities.Add(child1);

            SelfReferencingComposition parent2 = new SelfReferencingComposition { ID = 3, Value = "C" };
            entities.Add(parent2);
            SelfReferencingComposition child2 = new SelfReferencingComposition { ID = 4, ParentID = 3, Parent = parent2, Value = "D" };
            parent2.Child = child2;
            entities.Add(child2);

            // parent with no children
            SelfReferencingComposition parent3 = new SelfReferencingComposition { ID = 5, Value = "C" };
            entities.Add(parent3);

            return entities;
        }
 private bool FilterParent(SelfReferencingComposition entity)
 {
     return (entity.ID == this.ParentID);
 }
        public void Entity_ChildCannotBeItsParent()
        {
            ConfigurableEntityContainer container = new ConfigurableEntityContainer();
            container.CreateSet<SelfReferencingComposition>(EntitySetOperations.All);
            EntitySet<SelfReferencingComposition> childSet = container.GetEntitySet<SelfReferencingComposition>();

            SelfReferencingComposition child = new SelfReferencingComposition() { ID = 1 };

            childSet.Attach(child);

            // Verify that changing the parent throws an exception.
            ExceptionHelper.ExpectInvalidOperationException(delegate
            {
                child.Parent = child;
            }, Resource.Entity_ChildCannotBeItsParent);
        }