本文整理汇总了C#中ObjectState.Attach方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectState.Attach方法的具体用法?C# ObjectState.Attach怎么用?C# ObjectState.Attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectState
的用法示例。
在下文中一共展示了ObjectState.Attach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Getting_object_reference_by_traversing_a_relation_preserves_identity_property
public void Getting_object_reference_by_traversing_a_relation_preserves_identity_property()
{
var parentObjectId = ObjectId.NewUniqueId();
var thisObjectState = new ObjectState(objectId, objectTypeId);
thisObjectState.Attach(parentObjectId, "Parent");
var parentObjectState = new ObjectState(parentObjectId, objectTypeId);
parentObjectState.Attach(objectId, "Children");
dataFacadeMock.Setup(x => x.GetById(objectId, changeSetId)).Returns(thisObjectState);
dataFacadeMock.Setup(x => x.GetById(parentObjectId, changeSetId)).Returns(parentObjectState);
var snapshot = objectFacade.GetSnapshot(changeSetId);
var objectDirectly = snapshot.GetById<TestingObject>(objectId);
var chidViaParentViaChild = objectDirectly.Parent.Children.First();
Assert.AreSame(chidViaParentViaChild, objectDirectly);
}
示例2: It_maps_non_single_valued_relations_to_refefences_to_proxy_objects
public void It_maps_non_single_valued_relations_to_refefences_to_proxy_objects()
{
const string relationName = "Parent";
var parentObjectId = ObjectId.NewUniqueId();
var thisObjectState = new ObjectState(objectId, objectTypeId);
thisObjectState.Attach(parentObjectId, relationName);
dataFacadeMock.Setup(x => x.GetById(objectId, changeSetId)).Returns(thisObjectState);
dataFacadeMock.Setup(x => x.GetById(parentObjectId, changeSetId)).Returns(new ObjectState(parentObjectId, objectTypeId));
var snapshot = objectFacade.GetSnapshot(changeSetId);
var o = snapshot.GetById<TestingObject>(objectId);
var parent = o.Parent;
Assert.IsNotNull(parent);
}
示例3: It_maps_relations_to_collections_of_proxy_objects
public void It_maps_relations_to_collections_of_proxy_objects()
{
const string relationName = "Children";
var firstChildObjectId = ObjectId.NewUniqueId();
var secondChildObjectId = ObjectId.NewUniqueId();
var parentObjectState = new ObjectState(objectId, objectTypeId);
parentObjectState.Attach(firstChildObjectId, relationName);
parentObjectState.Attach(secondChildObjectId, relationName);
dataFacadeMock.Setup(x => x.GetById(objectId, changeSetId)).Returns(parentObjectState);
dataFacadeMock.Setup(x => x.GetById(firstChildObjectId, changeSetId)).Returns(new ObjectState(firstChildObjectId, objectTypeId));
dataFacadeMock.Setup(x => x.GetById(secondChildObjectId, changeSetId)).Returns(new ObjectState(secondChildObjectId, objectTypeId));
var snapshot = objectFacade.GetSnapshot(changeSetId);
var o = snapshot.GetById<TestingObject>(objectId);
var collection = o.Children;
Assert.AreEqual(2, collection.Count());
}