public void ICVF_RemoveAt()
        {
            EntitySet <City>        entitySet;
            EntityCollection <City> entityCollection = this.CreateEntityCollection(out entitySet);
            IEditableCollectionView view             = this.GetIECV(entityCollection);

            City city = (City)view.AddNew();

            city.Name       = "Des Moines";
            city.CountyName = "King";
            city.StateName  = "WA";
            view.CommitNew();
            entityCollection.Add(this.CreateLocalCity("Normandy Park"));
            entityCollection.Add(this.CreateLocalCity("SeaTac"));

            // This one was added through the view and will be removed from both
            city = entityCollection.ElementAt(0);
            view.RemoveAt(0);
            Assert.IsFalse(entityCollection.Contains(city),
                           "EntityCollection should no longer contain the entity at index 0.");
            Assert.IsFalse(entitySet.Contains(city),
                           "EntitySet should no longer contain the entity at index 0.");

            // This one was added directly and will only be removed for the collection
            city = entityCollection.ElementAt(1);
            view.RemoveAt(1);
            Assert.IsFalse(entityCollection.Contains(city),
                           "EntityCollection should no longer contain the entity at index 1.");
            Assert.IsTrue(entitySet.Contains(city),
                          "EntitySet should still contain the entity at index 1.");
        }
Exemple #2
0
        public void RemoveAt(int index)
        {
            T oldItem = collection.ElementAt(index);

            if (oldItem != null)
            {
                collection.Remove(oldItem);
            }
        }