当前位置: 首页>>代码示例>>C#>>正文


C# EntitySet.SetSource方法代码示例

本文整理汇总了C#中EntitySet.SetSource方法的典型用法代码示例。如果您正苦于以下问题:C# EntitySet.SetSource方法的具体用法?C# EntitySet.SetSource怎么用?C# EntitySet.SetSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntitySet的用法示例。


在下文中一共展示了EntitySet.SetSource方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Add_ThenSetSourceIsInvalid

 public void Add_ThenSetSourceIsInvalid()
 {
     var people = new EntitySet<Person>();
     Assert.IsFalse(people.HasLoadedOrAssignedValues);
     people.Add(new Person { FirstName = "A", LastName = "B" });
     Assert.IsTrue(people.HasLoadedOrAssignedValues);
     people.SetSource(new[]{
         new Person { FirstName = "1", LastName = "2" }
     });
 }
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:EntitySetTest.cs

示例2: Clear_DoesNotResetSource

 public void Clear_DoesNotResetSource()
 {
     var people = new EntitySet<Person>();
     Assert.IsFalse(people.HasLoadedOrAssignedValues);
     people.Add(new Person { FirstName = "A", LastName = "B" });
     Assert.IsTrue(people.HasLoadedOrAssignedValues);
     people.Clear();
     Assert.IsTrue(people.HasLoadedOrAssignedValues);
     people.SetSource(new[]{
         new Person { FirstName = "1", LastName = "2" },
     });
 }
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:EntitySetTest.cs

示例3: Assign

 public void Assign()
 {
     var people = new EntitySet<Person>();
     people.SetSource(new[]{
         new Person { FirstName = "A", LastName = "B" },
     });
     Assert.IsTrue(people.IsDeferred);
     people.Load();
     Assert.IsTrue(people.HasLoadedOrAssignedValues);
     Assert.IsFalse(people.IsDeferred);
     people.Assign(new[]{
         new Person { FirstName = "1", LastName = "2" },
     });
     Assert.IsTrue(people.HasLoadedOrAssignedValues);
     Assert.AreEqual(1, people.Count);
     Assert.IsFalse(people.IsDeferred);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:EntitySetTest.cs

示例4: Contains_KillsDeferred

 public void Contains_KillsDeferred()
 {
     var people = new EntitySet<Person>();
     var p = new Person { FirstName = "A", LastName = "B" };
     people.SetSource(new[]{
         p
     });
     Assert.IsTrue(people.IsDeferred);
     Assert.IsTrue(people.Contains(p));
     Assert.IsFalse(people.IsDeferred);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:EntitySetTest.cs

示例5: SetSource_HasLoadedOrAssignedValues_Is_False_Until_Count

        public void SetSource_HasLoadedOrAssignedValues_Is_False_Until_Count()
        {
            var people = new EntitySet<Person>();

            people.SetSource(new[]{
                new Person { FirstName = "1", LastName = "2" }
            });

            Assert.IsTrue(people.IsDeferred);
            Assert.IsFalse(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(1, people.Count);
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.IsFalse(people.IsDeferred);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:14,代码来源:EntitySetTest.cs

示例6: SetSource_ThenSetSourceIsValid

        public void SetSource_ThenSetSourceIsValid()
        {
            var people = new EntitySet<Person>();

            people.SetSource(new[]{
                new Person { FirstName = "1", LastName = "2" }
            });
            
            Assert.IsTrue(people.IsDeferred);

            people.SetSource(new[]{
                new Person { FirstName = "A", LastName = "B" } 
            });

            Assert.IsTrue(people.IsDeferred);
        }
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:EntitySetTest.cs

示例7: SetSource_EntitySourceCanBeNull

 public void SetSource_EntitySourceCanBeNull()
 {
     var entities = new EntitySet<Person>();
     entities.SetSource(null);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:EntitySetTest.cs

示例8: Remove

        public void Remove()
        {
            var people = new EntitySet<Person>();
            var events = new List<ListChangedEventArgs>();
            people.ListChanged += (o, e) => events.Add(e);

            people.SetSource(new[]{
                new Person { FirstName = "(", LastName = ")" },
            });
            Assert.IsTrue(people.IsDeferred);
            Assert.IsFalse(people.Remove(null));
            AssertEqual(events);
            events.Clear();
            Assert.IsTrue(people.IsDeferred);

            var p = people[0];
            Assert.IsTrue(people.Remove(p));
            Assert.IsFalse(people.IsDeferred);
            Assert.AreEqual(0, people.Count);
            AssertEqual(events, 
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1));
        }
开发者ID:nlhepler,项目名称:mono,代码行数:22,代码来源:EntitySetTest.cs

示例9: ListChanged_WithSource

        public void ListChanged_WithSource()
        {
            // When is ListChanged emitted?
            // It's not always when you think it would be.
            var people = new EntitySet<Person>();
            var events = new List<ListChangedEventArgs>();
            people.ListChanged += (o, e) => events.Add(e);

            // This is also true if Enumerable.Empty<Person>() is used here.
            people.SetSource(new[]{
                new Person { FirstName = "(", LastName = ")" },
            });
            AssertEqual(events);
            Assert.IsTrue(people.IsDeferred);

            // *Initial* Add()/AddRange() is ignored.
            people.Add(new Person { FirstName = "A", LastName = "B" });
            people.AddRange(new[]{
                new Person { FirstName = "1", LastName = "2" },
                new Person { FirstName = "<", LastName = ">" },
            });
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.IsTrue(people.IsDeferred);
            AssertEqual(events);

            events.Clear();
            people.Clear();
            AssertEqual(events, 
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.Reset, 0, -1));
            Assert.IsFalse(people.IsDeferred);

            // Add()/AddRange() after a Clear has events.
            events.Clear();
            people.Add(new Person { FirstName = "A", LastName = "B" });
            people.AddRange(new[]{
                new Person { FirstName = "1", LastName = "2" },
                new Person { FirstName = "<", LastName = ">" },
            });
            AssertEqual(events, 
                new ListChangedEventArgs(ListChangedType.ItemAdded, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemAdded, 1, -1),
                new ListChangedEventArgs(ListChangedType.ItemAdded, 2, -1));

            events.Clear();
            var p = new Person { FirstName = "{", LastName = "}" };
            people.Insert(1, p);
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemAdded, 1, -1));

            events.Clear();
            Assert.IsTrue(people.Remove(p));
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemDeleted, 1, -1));

            events.Clear();
            people.RemoveAt(0);
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1));

            events.Clear();
            people[0] = p;
            AssertEqual(events,
                new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                new ListChangedEventArgs(ListChangedType.ItemAdded, 0, -1));
        }
开发者ID:nlhepler,项目名称:mono,代码行数:66,代码来源:EntitySetTest.cs

示例10: Item_IsDeferredSourceLoaded

 public void Item_IsDeferredSourceLoaded()
 {
     var people = new EntitySet<Person>();
     people.SetSource(new[]{
         new Person { FirstName = "A", LastName = "B" },
     });
     Assert.IsFalse(people.HasLoadedOrAssignedValues);
     Assert.IsTrue(people.IsDeferred);
     var p = people[0];
     Assert.IsTrue(people.HasLoadedOrAssignedValues);
     Assert.IsFalse(people.IsDeferred);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:EntitySetTest.cs

示例11: IndexOf_KillsDeferred

 public void IndexOf_KillsDeferred()
 {
     var people = new EntitySet<Person>();
     var p = new Person { FirstName = "A", LastName = "B" };
     people.SetSource(new[]{
         p
     });
     Assert.IsTrue(people.IsDeferred);
     Assert.AreEqual(0, people.IndexOf(p));
     Assert.IsFalse(people.IsDeferred);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:EntitySetTest.cs


注:本文中的EntitySet.SetSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。