本文整理汇总了C#中EntityEntry.SetOriginalEntityValue方法的典型用法代码示例。如果您正苦于以下问题:C# EntityEntry.SetOriginalEntityValue方法的具体用法?C# EntityEntry.SetOriginalEntityValue怎么用?C# EntityEntry.SetOriginalEntityValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityEntry
的用法示例。
在下文中一共展示了EntityEntry.SetOriginalEntityValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Adds_original_value_for_scalar_property_when_some_other_original_values_exist
public void Adds_original_value_for_scalar_property_when_some_other_original_values_exist()
{
var mockMemberMetadata1 = new Mock<StateManagerMemberMetadata>();
mockMemberMetadata1.Setup(m => m.IsComplex).Returns(false);
var mockMemberMetadata2 = new Mock<StateManagerMemberMetadata>();
mockMemberMetadata2.Setup(m => m.IsComplex).Returns(false);
var mockMetadata = new Mock<StateManagerTypeMetadata>();
mockMetadata.Setup(m => m.Member(1)).Returns(mockMemberMetadata1.Object);
mockMetadata.Setup(m => m.Member(2)).Returns(mockMemberMetadata2.Object);
var entry = new EntityEntry();
entry.SetOriginalEntityValue(mockMetadata.Object, 2, new object(), 7);
var userObject = new object();
var value = new object();
entry.SetOriginalEntityValue(mockMetadata.Object, 1, userObject, value);
Assert.Equal(1, entry.FindOriginalValueIndex(mockMemberMetadata1.Object, userObject));
Assert.Same(
value,
entry.GetOriginalEntityValue(mockMetadata.Object, 1, userObject, ObjectStateValueRecord.OriginalReadonly));
}
示例2: Updates_original_value_for_scalar_property
public void Updates_original_value_for_scalar_property()
{
var mockMemberMetadata = new Mock<StateManagerMemberMetadata>();
mockMemberMetadata.Setup(m => m.IsComplex).Returns(false);
var mockMetadata = new Mock<StateManagerTypeMetadata>();
mockMetadata.Setup(m => m.Member(3)).Returns(mockMemberMetadata.Object);
var entry = new EntityEntry();
var userObject = new object();
entry.SetOriginalEntityValue(mockMetadata.Object, 3, userObject, new object());
var value = new object();
entry.SetOriginalEntityValue(mockMetadata.Object, 3, userObject, value);
Assert.Equal(0, entry.FindOriginalValueIndex(mockMemberMetadata.Object, userObject));
Assert.Same(
value,
entry.GetOriginalEntityValue(mockMetadata.Object, 3, userObject, ObjectStateValueRecord.OriginalReadonly));
}
示例3: Updates_original_value_for_complex_property
public void Updates_original_value_for_complex_property()
{
var userObject = new object();
var oldComplexObject = new object();
var newComplexObject = new object();
var newValue = new object();
var complexMetadata = CreateComplexMetadata(userObject, oldComplexObject);
var scalarMetadata = CreateNestedScalarMetadata(newComplexObject, newValue);
var mockStateManager = new Mock<ObjectStateManager>();
mockStateManager
.Setup(m => m.GetOrAddStateManagerTypeMetadata(It.IsAny<EdmType>()))
.Returns(scalarMetadata);
var entry = new EntityEntry(mockStateManager.Object);
entry.SetOriginalEntityValue(complexMetadata, 3, userObject, newComplexObject);
var newValue2 = new object();
Mock.Get(scalarMetadata.Member(0)).Setup(m => m.GetValue(newComplexObject)).Returns(newValue2);
entry.SetOriginalEntityValue(complexMetadata, 3, userObject, newComplexObject);
Assert.Equal(0, entry.FindOriginalValueIndex(scalarMetadata.Member(0), oldComplexObject));
Assert.Same(
newValue,
entry.GetOriginalEntityValue(scalarMetadata, 0, oldComplexObject, ObjectStateValueRecord.OriginalReadonly));
}
示例4: Gets_DBNull_for_null_original_value
public void Gets_DBNull_for_null_original_value()
{
var mockMemberMetadata = new Mock<StateManagerMemberMetadata>();
mockMemberMetadata.Setup(m => m.IsComplex).Returns(false);
var mockMetadata = new Mock<StateManagerTypeMetadata>();
mockMetadata.Setup(m => m.Member(3)).Returns(mockMemberMetadata.Object);
var entry = new EntityEntry();
var userObject = new object();
entry.SetOriginalEntityValue(mockMetadata.Object, 3, userObject, null);
Assert.Same(
DBNull.Value,
entry.GetOriginalEntityValue(mockMetadata.Object, 3, userObject, ObjectStateValueRecord.OriginalReadonly));
}
示例5: Adds_original_value_for_complex_property_when_some_other_original_values_exist
public void Adds_original_value_for_complex_property_when_some_other_original_values_exist()
{
var mockMemberMetadata1 = new Mock<StateManagerMemberMetadata>();
mockMemberMetadata1.Setup(m => m.IsComplex).Returns(false);
var mockMemberMetadata2 = new Mock<StateManagerMemberMetadata>();
mockMemberMetadata2.Setup(m => m.IsComplex).Returns(false);
var mockMetadata = new Mock<StateManagerTypeMetadata>();
mockMetadata.Setup(m => m.Member(1)).Returns(mockMemberMetadata1.Object);
mockMetadata.Setup(m => m.Member(2)).Returns(mockMemberMetadata2.Object);
var userObject = new object();
var oldComplexObject = new object();
var newComplexObject = new object();
var newValue = new object();
var complexMetadata = CreateComplexMetadata(userObject, oldComplexObject);
var scalarMetadata = CreateNestedScalarMetadata(newComplexObject, newValue);
var mockStateManager = new Mock<ObjectStateManager>();
mockStateManager
.Setup(m => m.GetOrAddStateManagerTypeMetadata(It.IsAny<EdmType>()))
.Returns(scalarMetadata);
var entry = new EntityEntry(mockStateManager.Object);
entry.SetOriginalEntityValue(mockMetadata.Object, 2, new object(), 7);
entry.SetOriginalEntityValue(mockMetadata.Object, 1, new object(), 0);
entry.SetOriginalEntityValue(complexMetadata, 3, userObject, newComplexObject);
Assert.Equal(2, entry.FindOriginalValueIndex(scalarMetadata.Member(0), oldComplexObject));
Assert.Same(
newValue,
entry.GetOriginalEntityValue(scalarMetadata, 0, oldComplexObject, ObjectStateValueRecord.OriginalReadonly));
}