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


C# ChangeSet.GetAssociatedEntities方法代码示例

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


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

示例1: Associate_GetAssociatedEntities

        public void Associate_GetAssociatedEntities()
        {
            ChangeSet changeSet = new ChangeSet(this.GenerateEntityOperations(true));

            MockEntity1 clientEntity1 = changeSet.ChangeSetEntries.Select(e => e.Entity).OfType<MockEntity1>().First();
            MockEntity2 clientEntity2 = changeSet.ChangeSetEntries.Select(e => e.Entity).OfType<MockEntity2>().First();
            MockStoreEntity storeEntity = new MockStoreEntity();

            changeSet.Associate(clientEntity1, storeEntity, (c, s) => { });
            changeSet.Associate(clientEntity2, storeEntity, (c, s) => { });

            IEnumerable<MockEntity1> clientEntities1 = changeSet.GetAssociatedEntities<MockEntity1, MockStoreEntity>(storeEntity);
            Assert.IsNotNull(clientEntities1, "Expected to clientEntities1 to not be null.");
            Assert.AreEqual(1, clientEntities1.Count(), "Expected to find 1 clientEntity entry.");
            Assert.AreSame(clientEntity1, clientEntities1.Single(), "Expected to find clientEntity1.");

            IEnumerable<MockEntity2> clientEntities2 = changeSet.GetAssociatedEntities<MockEntity2, MockStoreEntity>(storeEntity);
            Assert.IsNotNull(clientEntities2, "Expected to clientEntities to not be null.");
            Assert.AreEqual(1, clientEntities2.Count(), "Expected to find 1 clientEntity entry.");
            Assert.AreSame(clientEntity2, clientEntities2.Single(), "Expected to find clientEntity2.");

            IEnumerable<object> clientEntities3 = changeSet.GetAssociatedEntities<object, MockStoreEntity>(storeEntity);
            Assert.IsNotNull(clientEntities3, "Expected to clientEntities to not be null.");
            Assert.AreEqual(2, clientEntities3.Count(), "Expected to find 2 clientEntity entries.");
            Assert.IsTrue(clientEntities3.Contains(clientEntity1), "Expected to find clientEntity1.");
            Assert.IsTrue(clientEntities3.Contains(clientEntity2), "Expected to find clientEntity2.");
        }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:27,代码来源:ChangeSetTests.cs


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