本文整理汇总了C#中ChangeSet.Associate方法的典型用法代码示例。如果您正苦于以下问题:C# ChangeSet.Associate方法的具体用法?C# ChangeSet.Associate怎么用?C# ChangeSet.Associate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChangeSet
的用法示例。
在下文中一共展示了ChangeSet.Associate方法的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.");
}